The Wayback Machine - https://web.archive.org/web/20240214183620/https://www.geeksforgeeks.org/python-pil-image-point-method/
Open In App
Related Articles

Python PIL | Image.point() method

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images. Image.point() Maps this image through a lookup table or function.
Syntax: Maps this image through a lookup table or function. Parameters: lut – A lookup table, containing 256 (or 65336 if self.mode==”I” and mode == “L”) values per band in the image. A function can be used instead, it should take a single argument. The function is called once for each possible pixel value, and the resulting table is applied to all bands of the image. mode – Output mode (default is same as input). In the current version, this can only be used if the source image has mode “L” or “P”, and the output has mode “1” or the source image mode is “I” and the output mode is “L”. Returns: An Image object.
Image Used:
   
  
# importing Image class from PIL package 
from PIL import Image 
  
# creating a object 
im = Image.open(r"C:\Users\System-Pc\Desktop\home.png") 
  
# using point function
threshold = 191  
im = im.point(lambda p: p >value threshold and 255)
im.show()

                    
Output: Another Example:Here changing threshold value. Image Used:
   
  
# importing Image class from PIL package 
from PIL import Image 
  
# creating a object 
im = Image.open(r"C:\Users\System-Pc\Desktop\home.png") 
  
# using point function
threshold = 120  
im = im.point(lambda p: p > threshold and 255)
im.show()

                    
Output:

Don't miss your chance to ride the wave of the data revolution! Every industry is scaling new heights by tapping into the power of data. Sharpen your skills and become a part of the hottest trend in the 21st century.

Dive into the future of technology - explore the Complete Machine Learning and Data Science Program by GeeksforGeeks and stay ahead of the curve.


Last Updated : 17 Jul, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials