ImageOps.equalize()
method equalizes the image histogram. This function applies a non-linear mapping to the input image, in order to create a uniform distribution of grayscale values in the output image.
Syntax: PIL.ImageOps.equalize(image, mask=None)
Parameters:
image: The image to equalize.
mask: An optional mask. If given, only the pixels selected by the mask are included in the analysis.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\sadow984\Desktop\download2.JPg" ) # applying equalize method im2 = ImageOps.equalize(im1, mask = None ) im2.show() |
Output: