Image Processing using PIL (Python Imaging Library)

Python Image Library is used for manipulating images and working with the different formats of images.

1. Reading

We can read the image using open function of image module of Python Image Library. This function will take path of your image as parameter.

2. Display properties of the image

we can see properties of the image like size, mode and format.

Size gives the(length, width)

Format gives our file format (png, jpeg, jpg)

Mode gives the channel format(HSV, RGB, BGR)

3. Crop

We can crop our image using crop() method. This crop method accepts 4-valued tuple represented as (left, top, right, bottom). Where left, top, right and bottom represents the pixel coords of area you want to crop out. it return a image object.

4. Rotate

We can rotate image using rotate() method.

This function accepts a angle parameter.

5. Transpose

We can change the orientation of image using transpose function. Transpose function takes one parameter that is method of transpose Image.FLIP_LEFT_RIGHT (This inverse the rows of image)

Image.FLIP_TOP_BOTTOM (This inverse the columns of image)

6. Convert to Black and White

We will use convert method from Image module that can convert image to Black and White image Convert function accepts on parameter. For Black and White simply pass a string L to convert the image to Black and White.

7. Image Enhancement

Image enhancement is increasingthe pixels quality so that image rsult is more suitale to be used. There are different kinds of image enhancement techniques are there in image processing. They include color, contrast, sharpness, brightness etc.

Color Enhancement in this type of enhancement image colors are enhanced Sharpness Enhancement in this type of sharpness contrast between dark and bright regions are increased Contrast Enhancement In this type of enhancement degree of color or grayscale variation are increased Brightness Enhancement In this type of enhancement overall image darkness is enhanced

Popular Posts

Spread the knowledge

Leave a Reply

Your email address will not be published. Required fields are marked *