Newsgroups: sci.image.processing
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!udel!gatech!concert!decwrl!cache.crc.ricoh.com!james
From: james@crc.ricoh.com (James Allen)
Subject: Re: wavelength <-> RGB?
Message-ID: <1995Feb8.004459.24023@crc.ricoh.com>
Organization: RICOH California Research Center
References: <1995Feb2.185009.7613@Princeton.EDU>
Date: Wed, 8 Feb 95 00:44:59 GMT
Lines: 41

In <1995Feb2.185009.7613@Princeton.EDU>,
	olszewsk@splash.Princeton.EDU (Jason Olszewski) writes:
>  Does anyone know of an algorithm for converting a wavelength (ie nanometer)
> to RGB values or vice-vera.  Any information or pointers would be very
> helpful.

I saw only one response to this and, while containing useful information,
it failed to answer the question.  I'll assume you've studied a FAQ and
try to summarize wavelength-->RGB.  The "vice versa" problem is ill-posed.

To represent a spectral color in a 3-coordinate linear system (e.g. R-G-B)
use something like
		( R )		 ( 1.91 -.53 -.29 ) ( x )
		( G )  = scale * ( -.98 2.00 -.03 ) ( y )
		( B )		 (  .06 -.12  .90 ) ( z )
where x,y,z are the functions of wavelength given in Table 1.1 on page 13 of
_Color Measurement_ by D.L. MacAdam, ISBN 3-540-10773-8, Springer-Verlag.
The table in MacAdam's book (wavelength --> x_bar,y_bar,z_bar) gives three
attributes of each wavelength but one parameter can be viewed as just a
net transducance.  Thus the table is functionally equivalent to the famous
CIE-1931 diagram --- with the third degree of freedom (brightness) being
light flux.  Depending on the application you may want to just set the
amplitude factor (`scale') to satisfy   Max(R,G,B) = 255.

I'm sure this table is in machine-readable form somewhere (in fact there must
be public-domain software to do this -- I've waited this long to respond to
this question since I felt sure someone would point to such a machine-readable
table.)

The formula will produce negative numbers for R,G or B all along the spectrum.
This is because the rainbow is maximally "colorful" and thus outside any RGB
gamut.

I hope this helps.

> Thanks,
>  Jason
> PS. have a nice day

Thanks and same to you,
James
