I'm interested in equalizing a color image. What I'm doing is to start with an RGB image and convert it to YIQ values according to this article. After that I can obtain a greyscale version of the image by considering luminance levels given by Y. Applying an algorithm to that greyscale image, I can get a more or less equalized version of the greyscale version of the original image. I'd like to produce a new RGB image that preserves the colors of the original one and corrects the luminance values, to get a luminance-equalized RGB version of the original image.
First, I tried to convert the YIQ values back to RGB but considering for Y the modified values after equalization. With this approach I got RGB values out of [0,1].
Because that first approach did not work, I tried to do the following with a relative level of success. For each pixel, if Y' is the luminance level after equalizating and Y the original luminance value, I consider the new RGB values given by R' = (Y'/Y) R, G' = (Y'/Y) G and B' = (Y'/Y) B. That is, I escalated the luminance level preserving proportionality in the distribution of RGB components.
Even though the second approach worked, I have the problem that some of the colors in the original image look different after the equalization. This effect is more or less percievable depending on the original image. My question is, what is a good, color-preserving approach for transforming the original RGB image into a new one with the luminance values corrected?
Note that in the second method(btw, the only one that worked), I have to replace the (Y'/Y) in the formulas by the minumum between (Y'/Y) and the maximum of (1/R), (1/G) and (1/B), so I don't get above 1 in any component. Of course, this is another drawback because for some pixels I can't get the luminance level calculated in the greyscale equalization step.