Formula to determine brightness of RGB color

前端 未结 20 3086
猫巷女王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-21 23:46

    For clarity, the formulas that use a square root need to be

    sqrt(coefficient * (colour_value^2))

    not

    sqrt((coefficient * colour_value))^2

    The proof of this lies in the conversion of a R=G=B triad to greyscale R. That will only be true if you square the colour value, not the colour value times coefficient. See Nine Shades of Greyscale

提交回复
热议问题