Python Computer Vision: Chapter 1 Image Processing basics, python Image Processing

Source: Internet
Author: User

Python Computer Vision: Chapter 1 Image Processing basics, python Image Processing
<Div class = "article_content tracking-ad" id = "article_content" data-mod = "popu_307" data-dsm = "post">

Chapter 1 basics of image processing <Ol class = "toc" style = "margin: 20px; padding: 0px; list-style-type: none; list-style-position: outside; color: rgb (34,34, 34); font-family: 'helvetica Neue ', 'luxi Sans', 'dejavu Sans ', Tahoma, 'hiragino Sans G', 'Microsoft yahei', STHeiti; font-size: 14px; line-height: 22.3999996185303px ">
<Li> <a style = "color: rgb (221,17, 68)" href = "http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-1" target = ""> 1.1 PIL-Python Image Library </a>
<Ol style = "margin: 0px; padding: 0px; list-style-type: none">
<Li style = "padding-left: 20px"> <a style = "color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-1-1 "target =" "> 1.1.1 format conversion </a> </li> <li style =" padding-left: 20px "> <a style =" color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-1-2 "target =" "> 1.1.2 create a thumbnail </a> </li> <li style =" padding-left: 20px "> <a style =" color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-1-3 "target =" "> 1.1.3 copy and paste the area </a> </li> <li style =" padding-left: 20px "> <a style =" color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-1-4 "target =" "> 1.1.4 Resize and rotate </a> </li> </ol>
</Li> <a style = "color: rgb (221,17, 68)" href = "http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-2" target = ""> 1.2 Matplotlib library </a>
<Ol style = "margin: 0px; padding: 0px; list-style-type: none">
<Li style = "padding-left: 20px"> <a style = "color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-2-1 "target =" "> 1.2.1 drawing, drawing, and line </a> </li> <li style =" padding-left: 20px "> <a style =" color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-2-2 "target =" "> 1.2.2 image contour and histogram </a> </li> <li style =" padding-left: 20px "> <a style =" color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-2-4 "target =" "> 1.2.4 interactive comments </a> </li> </ol>
</Li> <a style = "color: rgb (221,17, 68)" href = "http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-3" target = ""> 1.3 NumPy library </a>
<Ol style = "margin: 0px; padding: 0px; list-style-type: none">
<Li style = "padding-left: 20px"> <a style = "color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-3-1 "target =" "> 1.3.1 Image array representation </a> </li> <li style =" padding-left: 20px "> <a style =" color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-3-2 "target =" "> 1.3.2 grayscale transformation </a> </li> <li style =" padding-left: 20px "> <a style =" color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-3-3 "target =" "> 1.3-3 resize images </a> </li> </ol>
</Li> <a style = "color: rgb (221,17, 68)" href = "http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-3-3" target = ""> 1.3.3 histogram equalization </a>
<Ol style = "margin: 0px; padding: 0px; list-style-type: none">
<Li style = "padding-left: 20px"> <a style = "color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-3-4 "target =" "> 1.3.4 image average </a> </li> <li style =" padding-left: 20px "> <a style =" color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-3-5 "target =" "> 1.3.5 Principal Component Analysis </a> </li> <li style =" padding-left: 20px "> <a style =" color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-3-6 "target =" "> 1.3.6 Pickle module </a> </li> </ol>
</Li> <a style = "color: rgb (221,17, 68)" href = "http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-4" target = ""> 1.4 SciPy module </a>
<Ol style = "margin: 0px; padding: 0px; list-style-type: none">
<Li style = "padding-left: 20px"> <a style = "color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-4-1 "target =" "> 1.4.1 Image Blur </a> </li> <li style =" padding-left: 20px "> <a style =" color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-4-2 "target =" "> 1.4.2 image difference </a> </li> <li style =" padding-left: 20px "> <a style =" color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-4-3 "target =" "> 1.4.3 morphology-object count </a> </li> <li style =" padding-left: 20px "> <a style =" color: rgb (221,17, 68) "href =" http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-4-4 "target =" "> 1.4.4 useful SciPy module </a> </li> </ol>
</Li> <a style = "color: rgb (221,17, 68)" href = "http://yongyuan.name/pcvwithpython/chapter1.html#sec-1-5" target = ""> 1.5 more advanced example: image Noise Reduction </a> </li> </ol>
<Div class = "main" style = "margin: 0px 20px; color: rgb (34,34, 34); font-family: 'helvetica Neue ', 'luxi Sans ', 'dejavu Sans ', Tahoma, 'hiragino Sans G', 'Microsoft yahei', STHeiti; font-size: 14px; line-height: 22.3999996185303px ">
<H2 id = "sec-1-1" style = "font-size: 20px; margin: 20px 0px "> <a name =" t1 "target =" _ blank "> </a> 1.1 PIL-Python Image Library <P style = "margin-top: 1em; margin-bottom: 1em"> PIL (Python Imaging Library) the Image Library provides many common image processing and many useful basic image operations. PIL library <a style = "color: rgb (221,17, 68)" href = "http://www.pythonware.com/products/pil/" target = "_ blank"> [www.pythonware.com/products/pil/] </a>. The following is an example of reading an image from the original book P001-Fig1-1: </p>
<Div class = "highlight" style = "border: 1px solid rgb (153,153,153); width: 760px; margin: 20px 0px; background: rgb (238,238,238)">
<Pre style = "margin-top: 10px; margin-bottom: 10px; margin-left: 10px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.5 "> <code class =" language-python "style =" font-family: Las LAS, 'libation mono', Courier, monospace; font-size: 1em; border: none; background: rgb (238,238,238) "> <span class =" c "style =" color: rgb (64,128,128); font-style: italic "> #-*-coding: UTF-8-*-</span>
<Span class = "kn" style = "color: rgb (0,128, 0); font-weight: bold "> from </span> <span class =" nn "style =" color: rgb (255,); font-weight: bold "> PIL </span> <span class =" kn "style =" color: rgb (0,128, 0); font-weight: bold "> import </span> <span class =" n "> Image </span>
<Span class = "kn" style = "color: rgb (0,128, 0); font-weight: bold "> from </span> <span class =" nn "style =" color: rgb (255,); font-weight: bold "> pylab </span> <span class =" kn "style =" color: rgb (0,128, 0); font-weight: bold "> import </span> <span class =" o "style =" color: rgb (0, 102,102,102) "> * </span> <span class =" c "style =" color: rgb (64,128,128); font-style: italic ">#add Chinese font support </span>
<Span class = "kn" style = "color: rgb (0,128, 0); font-weight: bold "> from </span> <span class =" nn "style =" color: rgb (255,); font-weight: bold "> matplotlib. font_manager </span> <span class = "kn" style = "color: rgb (0,128, 0); font-weight: bold "> import </span> <span class =" n "> FontProperties </span>
<Span class = "n"> font </span> <span class = "o" style = "color: rgb (0, 102,102,102) ">=</span> <span class =" n "> FontProperties </span> <span class =" p "> (</span> <span class =" n"> fname </span> <span class = "o" style = "color: rgb (102,102,102) ">=</span> <span class =" s "style =" color: rgb (, 33) "> r" c: \ windows \ fonts \ SimSun. ttc "</span> <span class =" p ">, </span> <span class = "n"> size </span> <span class = "o" style = "color: rgb (0, 102,102,102) ">=</span> <span class =" mi "style =" color: rgb (102,102,102) "> 14 </span> <span class =" p ">) </span>
<Span class = "n"> figure </span> <span class = "p"> () </span> <span class = "n"> pil_im </span> <span class = "o" style = "color: rgb (0, 102,102,102) ">=</span> <span class =" n "> Image </span> <span class =" o "style =" color: rgb (102,102,102) ">. </span> <span class = "n"> open </span> <span class = "p"> (</span> <span class = "s" style =" color: rgb (186, 33, 33) "> '.. /data/empire.jpg '</span> <span class = "p">) </span>
<Span class = "n"> gray </span> <span class = "p"> () </span>
<Span class = "n"> subplot </span> <span class = "p"> (</span> <span class = "mi" style = "color: rgb (102,102,102) "> 121 </span> <span class =" p ">) </span>
<Span class = "n"> title </span> <span class = "p"> (</span> <span class = "s" style = "color: rgb (186, 33, 33) "> u 'original' </span> <span class =" p ">, </span> <span class = "n"> fontproperties </span> <span class = "o" style = "color: rgb (0, 102,102,102) ">=</span> <span class =" n "> font </span> <span class =" p ">) </span>
<Span class = "n"> axis </span> <span class = "p"> (</span> <span class = "s" style = "color: rgb (186, 33, 33) "> 'off' </span> <span class =" p ">) </span>
<Span class = "n"> imshow </span> <span class = "p"> (</span> <span class = "n"> pil_im </span> <span class = "p">) </span> <span class = "n"> pil_im </span> <span class = "o" style = "color: rgb (0, 102,102,102) ">=</span> <span class =" n "> Image </span> <span class =" o "style =" color: rgb (102,102,102) ">. </span> <span class = "n"> open </span> <span class = "p"> (</span> <span class = "s" style =" color: rgb (186, 33, 33) "> '.. /data/empire.jpg '</span> <span class = "p">) </span> <span class = "o" style = "color: rgb (102,102,102) ">. </span> <span class = "n"> convert </span> <span class = "p"> (</span> <span class = "s" style =" color: rgb (186, 33, 33) "> 'l' </span> <span class =" p ">) </span>
<Span class = "n"> subplot </span> <span class = "p"> (</span> <span class = "mi" style = "color: rgb (102,102,102) "> 122 </span> <span class =" p ">) </span>
<Span class = "n"> title </span> <span class = "p"> (</span> <span class = "s" style = "color: rgb (186, 33, 33) "> u 'grayscale out' </span> <span class =" p ">, </span> <span class = "n"> fontproperties </span> <span class = "o" style = "color: rgb (0, 102,102,102) ">=</span> <span class =" n "> font </span> <span class =" p ">) </span>
<Span class = "n"> axis </span> <span class = "p"> (</span> <span class = "s" style = "color: rgb (186, 33, 33) "> 'off' </span> <span class =" p ">) </span>
<Span class = "n"> imshow </span> <span class = "p"> (</span> <span class = "n"> pil_im </span> <span class = "p">) </span> <span class = "n"> show </span> <span class = "p"> () </span>
</Code> </pre>
</Div>
<P style = "margin-top: 1em; margin-bottom: 1em"> run the above code to get the first two pictures in the original book P002-Fig1-1, as shown below:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.