Research breakthrough possible @S-Logix pro@slogix.in

Office Address

  • 2nd Floor, #7a, High School Road, Secretariat Colony Ambattur, Chennai-600053 (Landmark: SRM School) Tamil Nadu, India
  • pro@slogix.in
  • +91- 81240 01111

Social List

Image processing with pillow?

Description

To write a piece of python code for image processing with the help of pillow library in python.

Input

PNG Image.

Output

  Gray_scale image

  Blurred version of original image.

Process

  Load the image source.

  Import pillow library.

  Convert the image into gray_scale image.

  Make the image blurred using pillow filter.

  Save both the images.

Sample Code

#import pillow library
from PIL import Image, ImageFilter

#load image
image = Image.open(‘ml_map.png’)

#The file format of the source file
print(“Image format\n”,image.format,”\n”)

#The pixel format used by the image
print(“Image mode\n”,image.mode,”\n”)

#Image size, in pixels
print(“Image size\n”,image.size,”\n”)

#Convert original into gray_scale image
greyscale_image = image.convert(‘L’)

#Show the grayscale image
greyscale_image.show()

#save the gray_scale image
greyscale_image.save(“gray_scale.png”)

#Blur the image
blurred = image.filter(ImageFilter.BLUR)

#Display blurred images
blurred.show()

#save the new image
blurred.save(“blurred.png”)

Screenshots
Image size, in pixels
Image processing with pillow
Image processing with pillow
Show the grayscale image