如何计算照亮图像的光源的色温?


14

如何计算照亮给定图像的光源的(等效于黑体)色温?下面是Adobe Lightroom操纵色温和RGB直方图偏移的屏幕截图。给定图像的RGB分量,如何计算它?我应该期望一个值-照明源的黑体等效温度,对吗?

4600千 23810千


我不确定这是否有意义。色温是光线的一种属性,就像在拍摄图像时用来照亮场景的灯一样。我不知道图像本身是否具有色温。例如,纯绿色图像的色温是多少?绿色甚至不在黑体光谱中。它是由高温光源照射下的深绿色物体还是由低温光源照射下的浅绿色物体产生的?
Endlith 2013年

我问题的最后一部分-“我应该期望一个值-照明源的黑体等效温度,对吗?” 我不清楚吗?如果是这样,请随时提出修改建议。如果您的表面是绿色,则视光源而定,外观会有所不同。我正在尝试查看绿色并计算照明源的(等效于黑体)温度-Photoshop和Light Room如何做到这一点?即使是纯绿色的对象也不应显示为-#00FF00(十六进制rgb)。
卢勋爵。

@endolith-我进行了一些更改。您认为问题现在更清楚了吗?
卢勋爵。

好的,这更有意义,但是我仍然不确定是否有可能。不同色温源照亮的两种绿色阴影不能产生相同的输出图像吗?那么,如何在不知道物体和相机属性的情况下分辨出光源的色温呢?
Endlith 2013年

@endolith-可以吗?我不确定。我认为可能会。相机内置了白平衡控制。但是大多数图像具有多种阴影,这似乎是通过直方图分析的-随机的。因此,可能存在处于特定温度的置信区间。此外,相机和图片也具有一些元数据。我感觉这是专家驱动的方程式-有人(专家)对其进行了校准以给出一个数字。就像* C或* F一样-谁决定将水的凝固点设置为0 * C或32 * F?
卢勋爵。

Answers:


10

论文(PDF下载)给出了下面的公式计算的相关色温(CCT)。他们没有明确说出(或者我错过了),但是他们的例子使我推断他们假设RGB值为0-255。

1.如下将RGB值转换为CIE三刺激值(XYZ):

X=-0.14282[R+1.54924G+-0.95641
ÿ=-0.32466[R+1.57837G+-0.73191=一世ü一世ñ一种ñCË
Z=(0.68202)(R)+(0.77073)(G)+(0.56332)(B)

2.计算归一化色度值:

x=X/(X+Y+Z)
y=Y/(X+Y+Z)

3.根据以下公式计算CCT值:

CCT=449n3+3525n2+6823.3n+5520.33

where n=(x0.3320)/(0.1858y)

可以组合起来形成以下等式:

CCT=449n3+3525n2+6823.3n+5520.33
where n=((0.23881)R+(0.25499)G+(0.58291)B)/((0.11109)R+(0.85406)G+(0.52289)B)

I am not sure about applying this to an image, but if you just want a single, generalizing number, than you could perhaps use some sort of averaging? Either find an acceptable "average" RGB value for the image (eg. the centroid) and use that to calculate a temperature or (a much more computationally expensive option) calculate the temperature for each pixel in the image and take the average of those results.

Also, bear in mind that CCT is only an approximate metric for most colors, since only a single curve in the color space actually represents color which can be obtained from a real world black body radiator. Thus for all other colors, the calculated color temperature is simply an approximation of the black body temperature it most closely represents. Thus, for some colors (especially greens) it can actually be a somewhat meaningless value, at least in a physical sense. This is illustrated well in the following image (from the wikipedia article on color temperature).

The black line in the image represents the Planckian Locus of colors which could actually be produced by block body radiation. The smaller crossing lines represent the isotherms of the CCT approximation nearbye.

Also, since your question specifically references Adobe Lightroom, I found this while searching around:

The sliders [in Adobe Lightroom] adjust not the black body temp of the light, but the compensation applied to the image to compensate for the black body temp of the light. This goes the other way round.

So bear in mind that the color temperature you see on the Lightroom slider will not be the same as those calculated from the above formulae.


Please be advised that the RGB-XYZ transform used above appears to be specific to the colour space used by a certain hardware. It is most certainly not correct for sRGB, which is what is most probably being used in OP's case. Refer to the correct transforms in the sRGB standard
awdz9nld

Note also that the Y component in CIE 1931 denotes luminance, as opposed to illuminance
awdz9nld

0

I've calculated some colors according to your formulae, and as I see in some cases it works, while in some other cases - such as red (255 0 0) and blue (0 0 255) - it gives wrong answer:

  • white (255 255 255): n = 0.4049, CCT = 8890.77 K -> seems to be correct
  • yellow (255 255 0): n = -0.6646, CCT = 2410.65 K -> seems to be correct
  • green (0 255 0): n = -0.2986, CCT = 3785.42 K -> seems to be correct
  • cyan (0 255 255): n = 0.9902, CCT = 16168.7 K -> seems to be correct
  • magenta (255 0 255): n = -0.5428, CCT = 2783.54 K -> seems to be correct

however:

  • red (255 0 0): n = 2.1497, CCT = 40938.6 K -> seems to be wrong

  • blue (0 0 255): n = -1.1148, CCT = 1672.45 K -> seems to be wrong

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.