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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-07-20 03:36:33 +0000
Seen: 16 times
Last updated: Jul 20 '23