PIL image processing library

Python Imaging Library PIL (Python Image Library) is a third-party image processing libraries for python

Picture Archiving (Image Archives). PIL is ideal for batch jobs picture archiving and image. You can use the PIL create thumbnails, convert image formats, image printing and so on.
The image shows (Image Display). PIL newer version includes support for Tk PhotoImage, BitmapImage well as Windows DIB and other interfaces. PIL support many GUI framework interface, can be used for image display.
Image Processing (Image Processing). PIL include basic image processing functions, including processing point, using a large number of convolution kernel (convolution kernels) as filter (filter), as well as color space conversion. PIL library size also supports conversion, image rotation, and any affine transformation of the image. PIL Some histogram method that allows you to show
some of the statistical properties shown in the image. This can be used for automatic image contrast enhancement, as well as statistical analysis of global and so on.

Summed up as follows PIL library of common methods

Image class function

Open 1. ( filename ) : image file from a loading parameter. Recommended file full path , as the following files are located in d disk

 

New new 2. ( the MODE, size, color ) : This function creates a given mode ( the MODE ) and size ( size picture) if omitted color parameter, the images created by the black filled up, if the color parameter is None value , the picture has not initialized.

Open 3. ( StringIO.StringIO (Buffer) ) : acquiring an image from a string.

4.frombytes ( MODE , size , Data ): The pixel ( Data create images)

5.verify : image file integrity check returns an exception.

Image class of common properties

1.format : identifying origin or image format, if the image is not read from a file, is none

2.mode : color mode image, ' L ' is a gray image, ' the RGB ' true color images, " CMYK " publishing the image.

3.size : image width and height in pixels, the return value is two tuple.

4.palette : Palette property returns a ImagePalette type

Image methods of the class

1.seek (frame): Go and returns the specified frame images

2.tell (): returns the current frame number

On Groceries by ( filename , format ): Save the image as filename file name, format is the picture format

4.convert ( MODE ): using different parameters, converts the image to a new model

5.thumbnail ( size ): create thumbnail images, size binary size of a thumbnail Ganso

6.resize ( size ): Press size resized image, a copy.

7.rotate ( angle ): Press the angle angle angle of rotation, a copy.

8.point ( func ) : The function func operate on the function of each element, returns a copy of the image,

9.split (): extracting RGB for each color channel of the image, return a copy of the image,

10.merge ( mode , bands Scrap ): merge channel, wherein the mode represents a color, bands Scrap represents the new color channels.

11.blend ( im1 , im2 , Alpha ) : The two images im1 and im2 according to the following formula to generate a new interpolated FIG IM3 , im1 * ( 1.0-Alpha ) + im2 * Alpha.

12.getbands () Returns the tuple comprises for each channel name. For example, for an RGB image is returned ( "R", "G", "B").

13.getbbox () is calculated bounding box of the image non-zero region. The bounding box is a 4-tuple, define the left, upper, right and lower pixel coordinates. If the image is empty, this method will return null.

14.getextrema () returns a 2-tuple, including minimum and maximum values ​​in the image. This method returns the minimum and maximum 2-tuple of the three channels R / G / B.

15.getpixel () Returns a pixel value to a given position. If the image is a multi-channel, a tuple is returned. The method performs more slowly;

 

Refer to the specific use: https: //blog.csdn.net/leemboy/article/details/83792729 depth_1-utm_source = distribute.pc_relevant.none-task & utm_source = distribute.pc_relevant.none-task and https:? //Www.jb51 .net / article / 161051.htm

 

Guess you like

Origin www.cnblogs.com/jiaoshuaifeng/p/Shorwin.html