Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Just a simple contrast and saturation enhancement. Nothing fancy.

like image 964
TIMEX Avatar asked Nov 10 '10 08:11

TIMEX


Video Answer


1 Answers

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)

like image 130
jcomeau_ictx Avatar answered Sep 29 '22 18:09

jcomeau_ictx