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:

Recommended Posts:
- Difference between Method Overloading and Method Overriding in Python
- class method vs static method in Python
- Python | set() method
- Python | next() method
- Python | os.dup() method
- Python - PyTorch div() method
- Python PIL | getpalette() Method
- Python: filecmp.cmp() method
- Python Pytorch eye() method
- Python | os.chdir() method
- Python | Numpy np.fft() method
- Python | isinstance() method
- Python PIL | putdata() method
- Python | numpy.ma.ids() method
- Python | os.utime() method
- Python | os.kill() method
- Python PIL | GaussianBlur() method
- Python PIL | getcolors() Method
- Python | os.WIFSTOPPED() method
- Python | os.WIFCONTINUED() method
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.

