如何计算照亮给定图像的光源的(等效于黑体)色温?下面是Adobe Lightroom操纵色温和RGB直方图偏移的屏幕截图。给定图像的RGB分量,如何计算它?我应该期望一个值-照明源的黑体等效温度,对吗?
如何计算照亮给定图像的光源的(等效于黑体)色温?下面是Adobe Lightroom操纵色温和RGB直方图偏移的屏幕截图。给定图像的RGB分量,如何计算它?我应该期望一个值-照明源的黑体等效温度,对吗?
Answers:
该论文(PDF下载)给出了下面的公式计算的相关色温(CCT)。他们没有明确说出(或者我错过了),但是他们的例子使我推断他们假设RGB值为0-255。
1.如下将RGB值转换为CIE三刺激值(XYZ):
2.计算归一化色度值:
3.根据以下公式计算CCT值:
可以组合起来形成以下等式:
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.
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:
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