Search code examples
algorithmcolorsrgbformulaluminance

How to determine luminance %?


According to http://www.workwithcolor.com/color-luminance-2233.htm, RED (#FF0000) has Luminance: 54%. and light pink (#FF8080) has Luminance: 89%. Our designers like it but how is it determined? Try here: http://www.workwithcolor.com/hsl-color-schemer-01.htm

I tried using relative luminance formula published by W3C and although the range is [0,1], red is 0.21 and white is 1.00.

I'm thinking, maybe what workwithcolor does is first covert the color into grayscale, and read the luminance of the gray. I tried it but it still doesn't give the same result.

I've tried so far : http://jsfiddle.net/HytZQ/


Solution

  • Check the formula here: Formula to determine brightness of RGB color

    Luminance (standard, objective): (0.2126*R) + (0.7152*G) + (0.0722*B)
    

    Put R=255, and G=B=0, you'll get 54

    Edit: For relative luminance, divide by the maximum (255) you get 21%

    For white, you get 100%