I am reading a book for image processing algorithms (Andreas Koschan, Mongi Abidi: Digital Color Image Processing) and for the contrast algorithm it says that I can either go RGB->HSL or RGB->HSI first and than apply a contrast technique for grayscale images, on the lightness component.

Then it gives this formula only, not other formulas for color conversion:

$$L(x,y) = 0.299*R(x,y) + 0.587*G(x,y) + 0.114*B(x,y)$$

This formula is neither for the L in HSL, neither for the I in HSI and that is what confuses me.

Can you explain what this formula stands for, and maybe help with the appropriate conversion formulas?



L(x,y) here is a function for luma, a non-linear approximation of luminance. As you can see, it's the weighted sum of the R'G'B' values. The prime symbol (') indicates that they have been gamma-corrected for perceptual uniformity. The coefficients used in this case are standardized by ITU-R Recommendation BT.601. Other standards, such as BT.709 (which may be preferred for its higher accuracy), exist as well.

See: http://en.wikipedia.org/wiki/HSL_and_HSV#Lightness. I can't answer whether you can use luma and still say that it's a component of HSL or HSI. If the author of the book gave you that formula, I suspect you can assume so, at least for that text.

|improve this answer|||||

There are many ways of RGB to Grayscale conversion.

The HSL/HSB/HSI/HSV models can be used, but you need only the intensity component, so the color conversion is not necessary.

I found a Wikipedia article that explains the intensity component in HSL and HSV models. It is basically the axis connecting vertices of RGB cube corresponding to black and white colors.

The weighted average formula you wrote provides gray values that better correspond to human vision response (you can see that green has greatest weight, then red and then blue - the values correspond to human sensitivity to the RGB primaries).

If you need extra accuracy, be careful about which RGB you use. sRGB is used mostly and it have a gamma value of 2.2, so the intensities are non-linear. When with "advanced" model such as Lab, the L component comes from CIE XYZ model, where the XYZ is linearized RGB. So the conversion to XYZ or Lab, extracting luminance and then converting back to non-linear sRGB is the most accurate way, but computationally most expensive. (My description is maybe not much accurate, please see corresponding articles about color models for more information).

|improve this answer|||||
  • $\begingroup$ What do you mean when you say XYZ is linearized RGB? CIELAB is non-linear. $\endgroup$ – someguy Jun 28 '12 at 17:15
  • $\begingroup$ Yes, CIELAB is nonlinear. I talked about XYZ, which are linearly transformed linear RGB responses. The point was that if one want to work in Lab to adjust gray values, the usual RGB (sRGB) images need to be converted to linear RGB first for accurate conversion to Lab. $\endgroup$ – Libor Jun 28 '12 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.