HomeLanguagesPython PIL | ImageOps.grayscale() method

Python PIL | ImageOps.grayscale() method

PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The ImageOps module contains a number of ‘ready-made’ image processing operations. This module is somewhat experimental, and most operators only work on L and RGB images.
ImageOps.grayscale() Convert the image to grayscale. The complete pixel turns to gray, no other color will be seen.
 

Syntax: PIL.ImageOps.grayscale(image) 
Parameters: 
image – The image to convert into grayscale.
Returns An image. 
 

Image Used: 
 

 

Python3




# Importing Image and ImageOps module from PIL package
from PIL import Image, ImageOps
     
# creating a image1 object
im1 = Image.open(r"C:\Users\System-Pc\Desktop\a.JPG")
 
# applying grayscale method
im2 = ImageOps.grayscale(im1)
 
im2.show()


Output:
 

 

RELATED ARTICLES

4 COMMENTS

Most Popular

Dominic
32727 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7105 POSTS0 COMMENTS
Nicole Veronica
12244 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12329 POSTS0 COMMENTS
Shaida Kate Naidoo
7220 POSTS0 COMMENTS
Ted Musemwa
7478 POSTS0 COMMENTS
Thapelo Manthata
7200 POSTS0 COMMENTS
Umr Jansen
7176 POSTS0 COMMENTS