lunes, 20 de octubre de 2008

Fix low contrast photos using python (PIL)

In this post i explain how to fix low contrast images using the equalization functions of the python image library PIL.

Suppose that you have a low contrast image like this one:


Now lets equalize it using python:

import Image,import ImageOps

im = Image.open('lowContrast.jpg')
im_eq = ImageOps.equalize(im)
im_eq.save('lowContrast_eq.jpg')


And the result is:


Now suppose that you have the same problem but only in one of the channels. Like in this one that has low contrast in the blue band.


No problem:

import Image,import ImageOps

im = Image.open('colorProblem.jpg')
r,g,b = im.split()
b = ImageOps.equalize(b)
im_e = Image.merge('RGB', (r,g,b))
im_e.save('colorProblem_beq.jpg')


The result:

2 comentarios:

hellanadam dijo...
Este comentario ha sido eliminado por el autor.
hellanadam dijo...

Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..
ios App Developer
Android App Developer
Mobile App Developer