RGB to Kelvin

Recommended Posts

Hi,

I would like to convert an rgb color value of an attribute at points to temperature (kelvin).

I am wondering if anyone is aware of any algorithm related to that.

cheers,

C

Share on other sites

this looks pretty good:

Share on other sites

Just thinking out loud - color of blackbody radiation can be represented by temperature in Kelvins, or RGB color it emits. So Kelvins to RGB mapping should be straight forward, but backwards it might be tricky, as a RGB value may not be present in blackbody radiation spectrum.

If I understand it right, then this plot is showing Kelvin temperatures mapped to RGB colors.

So solution that comes to my mind is to find a Kelvin value, which is closest to the given RGB value. One way would be to take an array of Kelvin values converted to RGB values and to find the closest match (based on euclidean distance). Or if array of Kelvin values is not dense enough, you can linearly interpolate between two closest points found. It is not very precise, but should be good enough for some cases.

Also, one more fancy thing would be to compute the distance of given RGB value and Kelvin sample in Lab color space, because if I remember correctly, then distances in Lab color space match the best to the perceived difference in colors  (Maybe it is some other space, you can look it up)

• 1

Share on other sites
On 6/29/2017 at 3:51 PM, michael said:

this looks pretty good:

here is a test with the equivalent code in VEX, this not answer the question, but maybe help to "reverse engineering" something .

anyway

as @Juraj said, build an array with kelvin-to-rgb values and match to the closest may do the trick, at least in a plausible approach.

maybe this chart is useful?

Kelvin-to-rgb-00.hipnc

Create an account

Register a new account