title: Histogram equalization with color correction (iPhone/objective-C)
body: <p>I am trying to implement a histogram equalization method (HE) for a UIImage in my iphone app. </p>
  
  <p>I read the following:</p>
  
  <p><a href="http://en.wikipedia.org/wiki/Histogram_equalization" rel="noreferrer">http://en.wikipedia.org/wiki/Histogram_equalization</a></p>
  
  <p>But it says:</p>
  
  <blockquote>
  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.
  </blockquote>
  
  <p>So would this be a feasible approach?</p>
  
  <ol>
  <li>Grab UIImage data and convert from RGB to HSL</li>
  <li>Apply HE on luminance channel</li>
  <li>convert data back to RGB</li>
  <li>Create new UIImage from data </li>
  </ol>
  
  <p>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?</p>
  
  <p>I would appreciate any pointers to objective-C code that does color corrected histogram equalization. </p>
  
  <p>I have looked at the library below, but it does not do any color correction for HE:</p>
  
  <p><a href="http://code.google.com/p/simple-iphone-image-processing/source/browse/#svn/trunk/Classes%3Fstate%3Dclosed" rel="noreferrer">http://code.google.com/p/simple-iphone-image-processing/source/browse/#svn/trunk/Classes%3Fstate%3Dclosed</a></p>
  
  <p>Thanks!</p>