# Confused about HSI and HSL color spaces

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?

Thanks

• could you tell us which book you are reading? – penelope Jun 28 '12 at 12:21
• Those are the NTSC weightings for luminance. Check the references in the lightness section here. – datageist Jun 28 '12 at 12:56
• – user1486293 Jun 28 '12 at 15:25

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.

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).

• What do you mean when you say XYZ is linearized RGB? CIELAB is non-linear. – someguy Jun 28 '12 at 17:15
• 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. – Libor Jun 28 '12 at 19:59