Using Python's PIL, how do I enhance the contrast/saturation of an image?


Question

Just a simple contrast and saturation enhancement. Nothing fancy.

1
7
11/10/2010 8:55:34 AM

Accepted Answer

Since PIL is dead for the most part. Install the Pillow fork instead, sudo pip install pillow, and use its ImageEnhance module http://pillow.readthedocs.org/en/3.0.x/reference/ImageEnhance.html

>>> from PIL import Image, ImageEnhance
>>> image = Image.open('downloads/jcfeb2011.jpg')
>>> contrast = ImageEnhance.Contrast(image)
>>> image.show()

(unenhanced)

>>> contrast.enhance(2).show()

(contrast enhanced)

21
8/5/2017 10:51:25 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon