9
$\begingroup$

I need to be able to convert an arbitrary emission spectrum in the visible spectrum range (i.e. for every wavelength between 380 and 780, I have a number between 0 and 1 that represents the "intensity" or dominance of that wavelength), and I need to be able to map any given spectrum into a particular color space (for now I need RGB or CIE-XYZ). Is it possible?

For the spectrum say I have the emission spectrum of a white light, then every wavelength in the spectrum will have an intensity of 1, whereas for a green-bluish light I'd have most of the wavelengths between 500 and 550 with an intensity close to 1, with other wavelengths gradually dropping in intensity. So the first spectrum should be converted to pure white whereas the other one would be converted to a green-bluish color in any color space.

Is there a way to do this?

$\endgroup$
4
  • $\begingroup$ possible duplicate of Conversion formula from spectrophotometer readings to any standard color space profile? $\endgroup$
    – Colin K
    Commented Dec 21, 2011 at 0:31
  • $\begingroup$ Also, this is a classic optics homework question. $\endgroup$
    – Colin K
    Commented Dec 21, 2011 at 0:31
  • 1
    $\begingroup$ This isn't homework and I'm not an optic physics student, I just happened to need to solve this problem and needed some guidance because I didn't understand what I found online via google. Thanks for the link to the question though. $\endgroup$
    – Thomas
    Commented Dec 21, 2011 at 0:53
  • 1
    $\begingroup$ White light is not a flat spectrum, it's whatever our eyes perceive as white. White is typically modeled by “standard illuminants”, such as D65 or D50, which mimic average daylight or sunlight spectra. $\endgroup$ Commented Dec 21, 2011 at 9:04

2 Answers 2

6
$\begingroup$

Human eye has three types of color receptors which respond differently to different parts of the spectrum. See this chart.

One way to tackle your challenge is to basically simulate what the eye does: you take the spectrum as input, calculate how much it would excite each of the three color receptors based on their sensitivity to different parts of the spectrum and then use the three resulting numbers as RGB corresponding to the spectrum.

In order to compute the excitation level, you can integrate the product of the sensitivity SC(λ) of each of the three color receptors with your spectral power distribution P(λ) to obtain the three RGB numbers:

\begin{equation} R = \int_{0}^{+\infty} S_R(\lambda) P(\lambda) d\lambda \end{equation} \begin{equation} G = \int_{0}^{+\infty} S_G(\lambda) P(\lambda) d\lambda \end{equation} \begin{equation} B = \int_{0}^{+\infty} S_B(\lambda) P(\lambda) d\lambda \end{equation}

For prototyping you can probably just assume the sensitivity SC(λ) functions to be appropriately scaled and translated Gaussian functions of the wavelength. As you refine your model you should seek better sensitivity functions for each of the three types of color receptors.

$\endgroup$
4
  • $\begingroup$ +1 my thoughts exactly :-) It would be great to find numerical data about the sensitivity functions somewhere. $\endgroup$
    – David Z
    Commented Dec 21, 2011 at 0:23
  • $\begingroup$ There are standard sensitivity functions produced from decades of experimentation. They are maintained by the International Commission on Illumination (CIE). You can find all of that data on the CIE website. $\endgroup$
    – Colin K
    Commented Dec 21, 2011 at 0:43
  • $\begingroup$ Thanks! I used the chart and quickly worked out the mean and sd's for the normal distributions of each color component and obtained this result with (RMean = 570, RSD = 70, GMean = 530, GSD = 50, BMean = 440 and BSD = 40): link. It's still missing the purple band on the left and a few other colors but that's because my approximation is pretty bad, I'll be looking at the CIE site to find the sensitivity functions. Thanks! $\endgroup$
    – Thomas
    Commented Dec 21, 2011 at 0:55
  • $\begingroup$ @Thomas Did you find the sensitivity functions on the CIE website ? If yes, where ? Thank you ! $\endgroup$
    – james
    Commented Sep 6, 2017 at 9:04
0
$\begingroup$

The other answer is correct, but doesn't give the full information on how to do the calculation.

First, what you need is so called color matching functions (CMF). There are multiple families of them. The most used is the CIE 1931 color matching functions that characterize human eye in the 2° central part of the field of view (which corresponds to the fovea centralis of the retina).

The CMFs $f_n(\lambda)$ should be used as weight functions for the spectral power distribution $p(\lambda)$: to yield $n^{\text{th}}$ tristimulus value $c_n$, do

$$c_n=\int_{\lambda_{\text{min}}}^{\lambda_{\text{max}}} f_n(\lambda)p(\lambda)\,d\lambda.$$

Tables of numeric values of various CMFs including the CIE 1931 ones can be found e.g. here.

These CMFs give you a translation from spectral power density to CIE XYZ color space. The next step is to convert these values to the target color space. For example, the conversion to sRGB takes the three values $X,$ $Y,$ $Z$ as a vector, applies a particular linear transformation to this vector, and then applies the sRGB transfer function to each component of the resulting vector to yield the final gamma-compressed nonlinear values.

The matrix of this linear transformation can be found in Wikipedia for sRGB, or at the Bruce Lindbloom's page that lists forward and backward matrices for more RGB color spaces.

The sRGB transfer function is also given on the Wikipedia page linked above.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.