光和颜色入门 2023-04-02

1. 前情提要:每个眼睛看到的世界都是不一样的

射入眼睛的实际光量和人眼感知到的光量并不是一回事。眼睛只是一个光接收器,每个眼睛都有自己的“接收器属性”,因此每个眼睛对光的感知都是有差别的。人和动物对光的感知也是不同的,例如猫狗的色觉比人类少很多


同样的入射光,不同的“接收器”

2. understand luminous flux, luminous intensity, illuminance(照度), and luminance(辉度)

  • Luminous flux is a measurement of the total amount of light a light source emits uniformly, integrated over the entire angular span of the light. Luminous flux is measured in lumens (lm).
    形象的理解就是,Luminous flux 是光源朝各个角度发出的光线总数量。例如,某灯泡球状地向外发射了1000条光线

  • Luminous intensity, is Luminous flux per unit solid angle. It is evaluated with reference to visual sensation and is expressed in units of candela (cd), which is defined as the luminous intensity of a source that emits monochromatic radiation of frequency 540 × 10^12 Hz and that has a radiant intensity of 1/683 watt/steradian.
    Luminous intensity是单位立体角的Luminous flux,形象的理解,也就是单位立体角内的光线数量1 cd = 1 lm/sr
    一支普通蜡烛的发光强度约为1坎德拉(candlela)

“Candela” is Latin for “candle.” So one candela is equal to the brightness of a single average
candle. Two candelas is equal to the brightness of two candles, and so on.

  • Illuminance is the amount of light that falls on a surface per unit area. It is a measure of how much light illuminates a surface, wavelength-weighted by the luminosity function to correlate with human brightness perception. Illuminance is measured in lux (lux), which is equal to one lumen per square meter.
    Illuminance和Luminous intensity是类似的,Luminous intensity指一个单位立体角内的光线数量,而Illuminance指的是一个单位平面被照射到的光线数量(光通量密度),单位为勒克斯(lux), 1 lux = 1 lm/m²


    如图所示,图中r/2r/3r的三个平面都位于同一立体角内,该立体角内的光线数量一定,而距离光源越远的平面在单位面积上照射的光线量越少,照度越低

  • Luminance is a measure of the amount of light that shines from a source in a given direction. Luminance is measured in candela per square meter (cd/m²), or called 'nit'. cd/m² = lm/(sr*m²)
    辉度是指物体表面单位面积上反射或发射出的光通量密度,单位为坎德拉每平方米(cd/m² or nit


    还是这个图,假设表示的是单位立体角,并且每个A为1m²,那么形象地理解Luminance就是r位置上的A平面上的光线总量
    具象地理解500nit,就是约500支标准蜡烛,在辐射光线的单位立体角内照射到1平米平面的平面亮度

For example, if you have a light source that emits 1000 lumens of light uniformly across an area of one square meter, then the illuminance on that surface will be 1000 lux. If you have a white piece of paper that reflects 90% of the light that hits it, then the white paper's luminance will be higher than a black piece of paper that reflects only 10% of the light that hits it.

refer to
Luminous flux - Wikipedia

3. Lumen and Candela

Lumen (lm) and candela (cd) are both units of measurement for light, but they measure different things. Lumen measures the total amount of light emitted by a source, while candela measures the intensity of light emitted in a particular direction.

To convert lumens to candelas, you need to know the solid angle of the light source in steradians (sr). The formula to convert between candela and lumen is:

Luminous intensity (candela) = Luminous flux (lumen) / Solid angle (steradian)

I = Φ : Ω

Where I is luminous intensity in candela, Φ is luminous flux in lumens, and Ω is solid angle in steradians.

For example, if you have a lamp that emits 1000 lumens of light uniformly in all directions, then its luminous flux would be 1000 lm. If you focus all of that light into a beam that covers one steradian (a solid angle that covers an area equal to that of a sphere with a radius of one meter), then the luminous intensity of that beam would be 1000 cd


Luminance是客观的物理量,而Brightness是一种人类基于人眼接收器获得的主观感觉

4. Luminance

Luminance is linear

Luminance is linear, is the measurable quality of light that most closely corresponds to brightness, which we cannot objectively measure. We can only perceive it.

Luminance is not adjusted for human perception of lightness, because human perception of lightness is non-linear, which described below.

5. Lightness and Brightness, and the difference between them

lightness and brightness 都是人类的感觉
lightness描述的是物体的光反射率,比如金属的lightness比石头高,白纸lightness比黑纸高
brightness描述的是物体的亮感,比如电灯比蜡烛的brightness高

  • Lightness is the perceptual dimension that runs from black, through gray, to white, in a visual context. The physical counterpart of lightness is the permanent property of a surface that determines what percentage of light the surface reflects. Surfaces that appear white reflect about 90% of the light striking them. Black surfaces reflect about 3%. In short, lightness is perceived reflectance.
    Lightness是人类基于视觉上下文对物体表面的光反射率的描述
    例如,强光下的黑表面反射的光线数量,显然比深阴影中的白表面反射的光线数量多,但我们人眼不会认为黑表面更白,我们不会认为白天的黑色轿车比夜晚的白色轿车更白。我们仍然能感知,黑表面光反射率低。The black surface still looks black; the white looks white. Because to get the lightness of a surface right, the visual system must use the visual context. Indeed reflected light of any intensity, that is, any luminance, whatsoever, can be perceived as any shade of gray between black and white, depending on the context.

  • Brightness is the perception elicited by the luminance of a visual target, typically denoted as Q. Brightness is the perceptual dimension that runs from dim to bright. Like lightness, brightness is a perceptual term. The physical counterpart of brightness is called luminance — But, the perception is not linear to luminance, and relies on the context of the viewing environment (for example, see White's illusion).

    White's illusion

    Both of the gray bars of A and B have the same color and opacity,图中A/B实际上是同样的luminance,但是B看起来比A更亮,因为A嵌入的是白条,而B嵌入的是黑条,人对黑暗环境的光感更加明显,因此我们会感觉B看起来比A更亮
    更多地,红外线没有Brightness,因为人感觉不到

In short, if lightness is perceived reflectance in vision context, brightness is perceived luminance in vision context. The reflectance of an object is a relatively permanent property, whereas its luminance is transient. 它们都是发生在视觉上下文中的感觉

refer to https://www.cell.com/current-biology/pdf/S0960-9822(07)00878-0.pdf


6. Gamma correction

因为人眼机制的问题,客观上的【线性光通量变化即Luminance变化】反应在人眼中则变成一个【亮度即Brightness非线性变化】的过程。换句话说,可以理解成人眼内部对接收到的Luminance做了一个非线性的数学变换,人眼的output Luminance对应Brightness

下图描述了人眼和照相机作为光接收器时“感光量”的对比

eyes vs camera

With a digital camera, when twice the number of photons hit the sensor, it receives twice the signal (a "linear" relationship). Pretty logical, right? That's not how our eyes work.
Instead, we perceive twice the light as being only a fraction brighter — and increasingly so for higher light intensities (a "nonlinear" relationship)
在低Luminance区,Luminance提升delta,人眼感受到的光量不止提升delta;而在高Luminance区,Luminance提升delta,人眼感受到的光量提升少于delta

note: Compared to a camera, we are much more sensitive to changes in dark tones than we are to similar changes in bright tones. There's a biological reason for this peculiarity: it enables our vision to operate over a broader range of luminance. Otherwise the typical range in brightness we encounter outdoors would be too overwhelming.

另外,从图中我们除了发现人眼的非线性感光外,还可以发现,人眼感受到的中等光亮(中灰,middle gray),实际上只有20%的Luminance(以0%Luminance为黑色,100%Luminance为白色)


假设我们存储实际Luminance:
那么存储下来的不同高Luminance值,对人来说没什么区别,可以认为就是一个值。因此,对于人来说这样的存储方式是浪费的。
而存储下来的那些低Luminance值,相近的值带给人的感知亮度却区别明显。
对人而言,这是非常奇怪的

所以,我们的目标是,在人更敏感的低Luminance区,把感光值域放大(直观地看,就是增大感光函数图像的斜率,让轻微的Luminance扰动可以获得人眼中光亮的显著变化) ;在更不敏感的高Luminance区,把感光值域缩小(直观地看,就是降低感光函数图像的斜率)
也就是,拟合eyes curve,把实际光量转变成人的感知光量

于是,科学家就研究,然后得出了实际光通量和人眼感知光通量(也就是Brightness)的转化关系,这个转换称为伽马校正(Gamma correction)

在通常的照明的情况下,人类的视觉大体有伽马或者是幂函数的性质——伽马校正就是将camera curve转换成eyes curve

Gamma correction defines the relationship between a pixel's numerical value and its actual luminance, is used to code luminance values (proportional to intensity) into a perceptually-uniform domain, so as optimize perceptual performance of a limited number of bits in each RGB (or CMYK) component

out_luminance = a * in_luminance ^ gamma

其中a是一个常量,一般来说在a=1的通常情况下,输入输出的值的范围都是在0到1之间


  • 伽马值γ < 1的情况被称作编码伽马值(encoding gamma),而执行这个编码运算所使用上述幂定律的过程也叫做伽马压缩(gamma compression). When a digital image is saved, it's therefore "gamma encoded"

  • 相对地,伽马值γ > 1的情况有时也被称作解码伽马值(decoding gamma),而执行这个解码运算所使用上述幂定律的过程也叫做"伽马展开(gamma expansion)"

图像存储到硬盘的时候,伽马校正
读取图像进行显示的时候,伽马解码得到每个像素的实际luminance,便于显示元件展示

6.1 relative luminance calculate

relative luminance is more correctly symbolized as Y while L is normally used for absolute luminance as measured in nits (cd/m2).

The formula for relative luminance is Y = 0.2126R + 0.7152G + 0.0722B. The coefficients in the formula reflect human eye sensitivity to the particular color component: the human eye senses the green component most luminous, the red one - a bit less and the blue component is the least one of three.

relative luminance 是考虑了人眼机制的计算,因为人眼对不同色彩的光亮感知敏感度不同。可以把relative luminance视为Brightness的一种量化表征

// get sRGB gamma encoded color value
vR = sR / 255;
vG = sG / 255;
vB = sB / 255;


function sRGBtoLin(colorChannel) {
        // Send this function a decimal sRGB gamma encoded color value
        // between 0.0 and 1.0, and it returns a linearized value.

    if ( colorChannel <= 0.04045 ) {
        return colorChannel / 12.92;
    } else {
        return pow((( colorChannel + 0.055)/1.055),2.4);
    }
}

// find Luminance (Y) apply the standard coefficients for sRGB
Y = (0.2126 * sRGBtoLin(vR) + 0.7152 * sRGBtoLin(vG) + 0.0722 * sRGBtoLin(vB))

6.2 lightness calculate

// use Y above as input
function YtoLstar(Y) {
        // Send this function a luminance value between 0.0 and 1.0,
        // and it returns L* which is "perceptual lightness"

    if ( Y <= (216/24389)) {       // The CIE standard states 0.008856 but 216/24389 is the intent for 0.008856451679036
        return Y * (24389/27);  // The CIE standard states 903.3, but 24389/27 is the intent, making 903.296296296296296
    } else {
        return pow(Y,(1/3)) * 116 - 16;
    }
}

L* is a value from 0 (black) to 100 (white) where 50 is the perceptual "middle grey". L* = 50 is the equivalent of Y = 18.4, or in other words an 18% grey card, representing the middle of a photographic exposure (Ansel Adams zone V).

Hue

Hue is the most basic of color terms and denotes an object’s color. When we say “blue,” “green,” or “red,” we’re talking about hue.

Hue is color (blue, green, red, etc.)

Value

Value could also be called “lightness.”
It refers to how light or dark a color is. Lighter colors have higher values. For example, orange has a higher value than navy blue or dark purple.
亮度就是Value,那Value是什么呢?Value就是量化的RGB值,我们可以直接加总RGB三个通道的分量作为亮度的表征
So, Black(0,0,0) has the lowest value of any hue, and white(255,255,255) the highest.
纯红的是(255,0,0),亮度是255,白色的RGB值都是255,亮度值就是255*3,因此value更强

如何改变亮度

Value can be changed by adding white or black to the hue. Value is also a measure of the intensity or strength of the light
亮度调节只增加黑白两种颜色
增加亮度: 通过给画面中所有色彩添加白色使得画面变亮,减少亮度: 通过给画面增加黑色使得画面变暗

  • A tint is formed when white is added to a hue, lightening it.

  • A shade is created when black is added to a hue, making it darker.

  • Tones are created when gray is added to a hue. Tones are generally duller or softer-looking than pure hues.

attention: any hue with White/Black/Gray added will has a [lower] Chroma, which described below

Chroma

Chroma refers to the purity of a hue, or its freedom from white or gray. 色彩纯度是指颜色的纯净程度,即颜色中所含的灰色成分的多少。纯度越高,颜色越鲜艳
A hue with high chroma has no black, white, or gray added to it.
Conversely, adding white, black, or gray reduces its chroma.

It’s similar to saturation but not quite the same.
Chroma can be thought of as the brightness of a color in comparison to white.

Saturation

Saturation refers to how a hue appears under particular lighting conditions. Think of saturation in terms of weak vs. strong or pale vs. pure hues

Chroma and saturation both measure how pure a color is. Saturation is a qualitative measure about how pure the color looks based on how it appears in its environment and the light. Chroma is the quantitative measure of how pure a color is compared to a similarly illuminated white area


所以,如果对纯红色增加亮度,就是在纯红色之上添加白色,这导致亮度上去后色彩饱和度的下降,这时我们需要适当增加饱和度

refer to
https://www.cambridgeincolour.com/tutorials/gamma-correction.htm
https://learnopengl.com/Advanced-Lighting/Gamma-Correction

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,080评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,422评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,630评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,554评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,662评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,856评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,014评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,752评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,212评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,541评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,687评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,347评论 4 331
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,973评论 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,777评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,006评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,406评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,576评论 2 349

推荐阅读更多精彩内容