Open In App

Python PIL | ImageEnhance.Color() and ImageEnhance.Contrast() method

Last Updated : 27 Jun, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The ImageEnhance module contains a number of classes that can be used for image enhancement.

ImageEnhance.Color() method -

This class can be used to adjust the color balance of an image, in a manner similar to the controls on a color TV set. An enhancement factor of 0.0 gives a black and white image. A factor of 1.0 gives the original image.
Syntax: ImageEnhance.Color(image) First, it is required to create an object of corresponding class in order to enhance image.
Python3
# This will import Image and ImageEnhance modules
from PIL import Image, ImageEnhance

# Opening Image
im = Image.open(r"C:\Users\Admin\Pictures\images.png")

# Creating object of Color class
im3 = ImageEnhance.Color(im)

# showing resultant image
im3.enhance(0.0).show()
Output: For first image factor = 0.0 and for second image factor is 5.0.

ImageEnhance.Contrast() method -

This class can be used to control the contrast of an image, similar to the contrast control on a TV set. An enhancement factor of 0.0 gives a solid grey image. A factor of 1.0 gives the original image. Syntax:
obj = ImageEnhance.Contrast(image) obj.enhance(factor) First, it is required to create an object of corresponding class in order to enhance image.
Python3
# This will import Image and ImageEnhance modules
from PIL import Image, ImageEnhance

# Opening Image
im = Image.open(r"C:\Users\Admin\Pictures\images.png")

# Creating object of Contrast class
im3 = ImageEnhance.Contrast(im)

# showing resultant image
im3.enhance(0.0).show()
Output: For first image factor is 5.0 and for second 0.0

Next Article
Practice Tags :

Similar Reads