Jump to content

RGB to Kelvin

Recommended Posts


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.



Share this post

Link to post
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)

  • Like 1

Share this post

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

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


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?






Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now