I need to be able to convert an arbitrary emission spectrum in the visible spectrum range (i.e. for

Alisa Durham

Alisa Durham

Answered question

2022-05-13

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?

Answer & Explanation

Eden Bradshaw

Eden Bradshaw

Beginner2022-05-14Added 19 answers

Human eye has three types of color receptors which respond differently to different parts of the spectrum
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 S C ( λ ) of each of the three color receptors with your spectral power distribution P ( λ ) to obtain the three RGB numbers:
R = 0 + S R ( λ ) P ( λ ) d λ
G = 0 + S G ( λ ) P ( λ ) d λ
B = 0 + S B ( λ ) P ( λ ) d λ
For prototyping you can probably just assume the sensitivity S C ( λ ) 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.
Daphne Fry

Daphne Fry

Beginner2022-05-15Added 3 answers

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 ( λ ) should be used as weight functions for the spectral power distribution p ( λ ): to yield n th tristimulus value c n , do
c n = λ min λ max f n ( λ ) p ( λ ) d λ .
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.

Do you have a similar question?

Recalculate according to your conditions!

New Questions in Atomic Physics

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?