Python PIL | ImageOps.postarize() method

PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. 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.posterize() Reduce the number of bits for each color channel.In every change of bit change of colour contraction will be seen

Syntax: PIL.ImageOps.posterize(image)

Parameters:
image – The image used to posterize.
bits – The number of bits to keep for each channel (1-8). Bit 8 is the max bit can be used by the channel.

Returns: An image.



Image Used:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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 posterize method 
im2 = ImageOps.posterize(im1, 2
  
im2.show()

chevron_right


Output:

bit– Taking bit 4 here to understand the change in colour by changing bits in channel.

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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 posterize method 
im2 = ImageOps.posterize(im1, 4
  
im2.show()

chevron_right


Output:

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.