Ask Your Question
4

What is the method for computing luminance using HSL?

asked 2023-07-20 03:36:33 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2023-07-20 03:50:02 +0000

nofretete gravatar image

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.

edit flag offensive delete link more

Your Answer

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

Add Answer


Question Tools

Stats

Asked: 2023-07-20 03:36:33 +0000

Seen: 16 times

Last updated: Jul 20 '23