Formula to determine brightness of RGB color

前端 未结 20 3004
猫巷女王i
猫巷女王i 2020-11-21 23:16

I\'m looking for some kind of formula or algorithm to determine the brightness of a color given the RGB values. I know it can\'t be as simple as adding the RGB values toget

相关标签:
20条回答
  • 2020-11-22 00:00

    I wonder how those rgb coefficients were determined. I did an experiment myself and I ended up with the following:

    Y = 0.267 R + 0.642 G + 0.091 B
    

    Close but but obviously different than the long established ITU coefficients. I wonder if those coefficients could be different for each and every observer, because we all may have a different amount of cones and rods on the retina in our eyes, and especially the ratio between the different types of cones may differ.

    For reference:

    ITU BT.709:

    Y = 0.2126 R + 0.7152 G + 0.0722 B
    

    ITU BT.601:

    Y = 0.299 R + 0.587 G + 0.114 B
    

    I did the test by quickly moving a small gray bar on a bright red, bright green and bright blue background, and adjusting the gray until it blended in just as much as possible. I also repeated that test with other shades. I repeated the test on different displays, even one with a fixed gamma factor of 3.0, but it all looks the same to me. More over, the ITU coefficients literally are wrong for my eyes.

    And yes, I presumably have a normal color vision.

    0 讨论(0)
  • 2020-11-22 00:04

    The inverse-gamma formula by Jive Dadson needs to have the half-adjust removed when implemented in Javascript, i.e. the return from function gam_sRGB needs to be return int(v*255); not return int(v*255+.5); Half-adjust rounds up, and this can cause a value one too high on a R=G=B i.e. grey colour triad. Greyscale conversion on a R=G=B triad should produce a value equal to R; it's one proof that the formula is valid. See Nine Shades of Greyscale for the formula in action (without the half-adjust).

    0 讨论(0)
提交回复
热议问题