Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Luminance can be computed using the following formula:

Luminance = (max(R,G,B) + min(R,G,B)) / 2

where R, G and B are the Red, Green and Blue components of the color respectively.

To convert RGB to HSL, we first need to normalize RGB values by dividing each by 255 to get the range [0,1]. Then we can calculate HSL values using the following formula:

Hue = arccos((0.5 * (2R - G - B)) / sqrt((R - G)^2 + (R - B)(G - B)))

Saturation = 1 - (3/(R + G + B))*min(R,G,B)

Lightness = (1/3)*(R+G+B)

where Hue is the color angle ranging from 0° to 360°, Saturation is the intensity of color ranging from 0 to 1, and Lightness is the brightness of color ranging from 0 to 1.

Having computed the HSL values, we can then use the earlier formula to find the Luminance value for the specific color.