Lightroom -like histogram in Python

I just added a dynamically-generated histogram to the image items on my site. It's not really usefull information in the context of viewing a photograph, it's more functional when editing, but being the uber-geek that I am, I thought it would still be interesting information to have on my site, right along with the exif data (aperature, focal length, etc).

But not just any histo

I didn't just want a black and white representation of all the image histogram, I wanted something like the pretty histogram in Adobe Photoshop Lightroom:

Lightroom Histogram

All in all the final version took me about 1.5 hours to write in Python using PIL. The semi-tricky part was getting the overlapping colors. It turned out to be about 70 lines of code, and could probably be done much better. On my local Ubuntu install, a typical image histogram is generated in about 5-10 ms, not bad for a skinny white guy :)

Check out an image or two to see the pretty histogram in action :) Next step, drop shadows on the layers...

Cheers, Aaron

Posted

Nov 19, 2008
by AnonymousUser

Categories

General Posts