The Wayback Machine - https://web.archive.org/web/20221026181556/https://www.geeksforgeeks.org/python-pil-imageops-solarize-method/
Skip to content
Related Articles

Related Articles

Python PIL | ImageOps.solarize() method

View Discussion
Improve Article
Save Article
  • Last Updated : 23 Dec, 2021
View Discussion
Improve Article
Save Article

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.solarize() Invert all pixel values above a threshold, threshold simply means image segmentation. 
 

Syntax: PIL.ImageOps.solarize(image, threshold=130) 
Parameters: 
image – The image to solarize. 
threshold – All pixels above this grayscale level are inverted.
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") 
  
# image segmentation 
# using threshold value = 130
# applying solarize method 
im2 = ImageOps.solarize(im1, threshold = 130) 
  
im2.show()

Output:
 

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!