Python PIL | ImageOps.postarize() method
Last Updated :
11 Jul, 2019
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:
from PIL import Image, ImageOps
im1 = Image. open (r "C:\Users\System-Pc\Desktop\a.JPG" )
im2 = ImageOps.posterize(im1, 2 )
im2.show()
|
Output:
bit– Taking bit 4 here to understand the change in colour by changing bits in channel.
from PIL import Image, ImageOps
im1 = Image. open (r "C:\Users\System-Pc\Desktop\a.JPG" )
im2 = ImageOps.posterize(im1, 4 )
im2.show()
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...