views:

128

answers:

1

I am trying to implement a histogram equalization method (HE) for a UIImage in my iphone app.

I read the following:

http://en.wikipedia.org/wiki/Histogram_equalization

But it says:

Still, it should be noted that applying the same method on the Red, Green, and Blue components of an RGB image may yield dramatic changes in the image's color balance since the relative distributions of the color channels change as a result of applying the algorithm. However, if the image is first converted to another color space, Lab color space, or HSL/HSV color space in particular, then the algorithm can be applied to the luminance or value channel without resulting in changes to the hue and saturation of the image.

So would this be a feasible approach?

  1. Grab UIImage data and convert from RGB to HSL
  2. Apply HE on luminance channel
  3. convert data back to RGB
  4. Create new UIImage from data

Will this be slow, I wonder? Also, will I have to deal with 8/16/24 bit data differently, as I have no idea what kind of image will be used with my app? Or can I assume 24 bit for images in the iPhone?

I would appreciate any pointers to objective-C code that does color corrected histogram equalization.

I have looked at the library below, but it does not do any color correction for HE:

http://code.google.com/p/simple-iphone-image-processing/source/browse/#svn/trunk/Classes%3Fstate%3Dclosed

Thanks!

A: 

Yes you can do it this way, that will work. Yes it will "cost more" since you have to do the conversion back and forth - but that's the price you will have to pay if you don't want to affect the hue and saturation. Is that worth it for the images you're correcting? It would depend on your application, are you OK with a hit in performance vs best quality? You will likely only have to deal with 8bit color components, you can assume "24 bit" for images but that's 3 x 8bit components The only way to know your answers though is to try.

Nektarios