Skip to main content
GameDev.net gamedev.net
🔒 Locked

How to convert Wavelength(nm) to RGB values

Started by Willywig Aug 14, 2002 at 9:13 PM 3 replies 7.5k views
Original Post
Willywig
Willywig
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
yellowjon
yellowjon
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.
Yann L
Yann L
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
Yann L
Yann L
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).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.