Open In App

Python PIL | ImageOps.postarize() method

Last Updated : 11 Jul, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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:




# 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()


Output:

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




# 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()


Output:


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads