Jump to content

RGB to Kelvin


csp

Recommended Posts

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.

PlanckianLocus.png

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
Link to comment
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:.

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?

http://www.vendian.org/mncharity/dir3/blackbody/UnstableURLs/bbr_color.html

 

 

 

Kelvin-to-rgb-00.hipnc

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...