1. Home
  2. Docs
  3. Computer Vision
  4. Introduction to OpenCV
  5. Opening Image Files in a ...
  6. ImageOps Module

ImageOps Module

ImageOps is a module that contains ready-made image processing operations

from PIL import ImageOps

After loading the image, it can be converted to grey scale as:

image_gray = ImageOps.grayscale(image_)

We can save the grey scale image and save intodesired format “jpg”

image_gray.save("NewImage.jpg") 
# saving the grey file in New file called NewImage.jpg

To open grey scale images

from PIL import ImageOps
image_gray = Image.open(“image.jpg”) # to open grey scale image
image_gray.mode #to display mode
image_gray.quantize(2) # use quantize to quantize the image. The input is the number ofquantization levels
L means Luminance

To process with color images

Baboon = Image.open(“baboon.jpg”)
Red, green, blue = baboon.split()
Good to Know
  • Different RGB channels can be obtained as grey scale images and assign them to the variable red, green and blue using the method split()
  • Red channel can be plotted as grey scale image. The red pixels in the grey scale plot of the red have a higher intensity

To process with color images

Loading

Views: 3

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments