确定RGB颜色感知亮度的公式 [英] Formula to determine perceived brightness of RGB color
问题描述
我正在寻找某种公式或算法来确定给定 RGB 值的颜色的亮度.我知道这不是将 RGB 值加在一起那么简单,总和越高越亮,但我有点不知从何开始.
该方法可能因您的需要而异.以下是 3 种计算亮度的方法:
亮度(某些颜色空间的标准):
(0.2126*R + 0.7152*G + 0.0722*B)
亮度(感知选项 2,计算速度较慢):
→sqrt( 0.241*R^2 + 0.691*G^2 + 0.068*B^2 )
sqrt( 0.299*R^2 + 0.587*G^2 + 0.114*B^2 )
(感谢 @MatthewHerbst) 来源
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 together and having higher sums be brighter, but I'm kind of at a loss as to where to start.
The method could vary depending on your needs. Here are 3 ways to calculate Luminance:
Luminance (standard for certain colour spaces):
(0.2126*R + 0.7152*G + 0.0722*B)
sourceLuminance (perceived option 1):
(0.299*R + 0.587*G + 0.114*B)
sourceLuminance (perceived option 2, slower to calculate):
→sqrt( 0.241*R^2 + 0.691*G^2 + 0.068*B^2 )
sqrt( 0.299*R^2 + 0.587*G^2 + 0.114*B^2 )
(thanks to @MatthewHerbst) source
[Edit: added examples using named css colors sorted with each method.]
这篇关于确定RGB颜色感知亮度的公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!