#### Archived

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

# How to convert Wavelength(nm) to RGB values

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

## 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 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 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 ]  XG = [-0.969256  1.875991  0.041556 ]* YB   [ 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 on other sites
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 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).

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 23
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631766
• Total Posts
3002233
×