Archived

This topic is now archived and is closed to further replies.

How to convert Wavelength(nm) to RGB values

This topic is 5604 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone out there know how to convert Wavelength(nm) to RGB values. for example 650 nm is (255,0,0) http://www.geo.fmi.fi/~tmakinen/bin/kwrgb.cgi I am really looking for an algorithm or c++/C code that can do this

Share this post


Link to post
Share on other sites
Maybe you could map the wavelength to the HSV color model first, then convert it to RGB. I know it''s not exactly a linear mapping (I''m pretty sure at least), but it shouldnt be too hard to approximate it fairly well and it would make it more intuitive.

Share this post


Link to post
Share on other sites
This is what you need to do:

first convert the spectral power distribution (SPD) to CIE XYZ tristimulus values, using the CIE colour matching curves. The process is described here.

Then, you can convert the CIE XYZ values to RGB by multiplying them by an appropriate colour transform matrix. The following one is the classical Rec.709 HDTV matrix, with D65 whitepoint:


R [ 3.240479 -1.53715 -0.498535 ] X
G = [-0.969256 1.875991 0.041556 ]* Y
B [ 0.055648 -0.204043 1.057311 ] Z


It''s a bit complicated to find the exact table values for the CIE curves on the net, if you don''t find them let me know, and I can post them.

/ Yann

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
And how does one handle the fact that we have 4 types of ?sense cells?

Or are the black/white cells fully saturated at usuall monitor intensities?

Share this post


Link to post
Share on other sites
quote:

Or are the black/white cells fully saturated at usuall monitor intensities?


Yep. AFAIK, the brain switches them off at normal intensities. They are only useful at night (that''s why you cannot see colours at very low intensity levels).

Share this post


Link to post
Share on other sites