Is it possible to answer my question definitely (assuming the monitor is perfect)? What would be the formula for calculating RGB values for a visible monochrome light with given wavelength?
Visible Light – What RGB Values Represent a 445nm Monochrome Light Source Color on a Computer Monitor
visible-lightwavelength
Related Solutions
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.
If you make the temperature very, very high (say $>10^{5}$ K) then the visible part of the spectrum lies in the Rayleigh-Jeans tail of the Planck spectrum.
Thus: $$B_{\nu} \simeq \frac{2\nu^2 kT}{c^2},$$ and the approximation becomes better and better as $kT \gg h\nu$. The equivalent expresson per unit wavelength interval is $$B_{\lambda} \simeq \frac{2c kT}{\lambda^4}$$
The general problem of converting from a spectrum to RGB values is discussed here. This involves doing an integration of the spectrum, weighted by visual perception sensitivity and then converting the resulting sums into RGB values. The process is described in some detail here.
No example is given for a very hot blackbody, though some tools are provided (C programs). However, I find this site has already done the calculations for blackbodies up to 30,000K (which is probably close to an asymptotic limit and gets RGB=#9fbfff (159,191,255).
Here is a plot of RGB values versus blackbody temperature from Tanner Helland. that seems to agree closely with this result (maybe 152,185,255 at 40,000 K) and where you can see the asymptotic behaviour.
Further edit: Wolfram Alpha has a calculator that goes up to 90,000K. This yields an RGB of 153.7,176.7,255, but given that the RGB for 30,000K is identical, I'm not sure I trust these exact values. In any case, the image below is what this looks like (courtesy of Emilio Pisanty).
Best Answer
First you consult a CIE 1964 Supplementary Standard Colorimetric Observer chart, and look up the CIE color matching function values for the wavelength you want:
For your desired wavelength:
Note: The chromacity coordinates are simply calculated from the CIE color matching functions:
Given that:
We can calculate:
You have a color specified using two different color spaces:
We can also add a third color space: xyY
We now have the color specified in 3 different color spaces:
So you've converted a wavelength of pure monochromatic emitted light into a XYZ color. Now we want to convert that to RGB.
How to convert XYZ into RGB?
XYZ, xyz, and xyY are absolute color spaces that describe colors using absolute physics.
Meanwhile, every practical color spaces that people use:
depends on some whitepoint. The colors are then described as being relative to that whitepoint.
For example,
But there is no such color as white. How do you define white? The color of sunlight?
Some people use the white of their (horribly orange) incandescent bulbs to mean white. Some people use the color of their florescent lights. There is no absolute physical definition of white - white is in our brains.
So we have to pick a white
We have to pick a white. Really it's you who has to pick a white. And there are plenty of whites to choose from:
I will pick a white for you. The same white that sRGB uses:
D65 (which has a color close to 6500K, but not quite because of the Earth's atmosphere), has a color of:
With that, you can convert your
XYZ
intoLab
(orLuv
) - a color-space equally capable of expressing all theoretical colors. And now we have a 4th color space representation of our 445 nm monochromatic emission of light:But you want RGB
Lab
(andLuv
) are color spaces that are relative to some white-point. Even though you were forced to pick an arbitrary white-point, you can still represent every possible color.RGB is not like that. With RGB:
If you specify an RGB color of (255, 0, 0), you are saying you want "just red". But there is no definition of red. There is no such thing as "red", "green", or "blue". The rainbow is continuous, and doesn't come with an arrow saying:
And again this means we have to pick three pick three primary colors. You have to pick your three primary colors to say what "red", "green", and "blue" are. And again you have many different definitions of Red,Green,Blue to choose from:
I'll pick for you. I'll pick these three colors:
Those were also the primaries chosen for by an international committee in 1996.
They created a standard that said everyone should use:
And they called that standard
sRGB
- and you can see these four points plotted out on a chromacity diagram:sRGB Chromacity Diagram (D65 & red,green,blue primaries)
The final push
Now that we have chosen our
we can now convert you XYZ color into RGB, using the sRGB choices for "red", "green", "blue", and "white":
Giving you your RGB of:
Unfortunately:
So we have to round:
Bonus - Where you color is
I wanted to point out that nearly everyone uses sRGB as the standard. It's a general standard for all digital cameras, for JPEGs on the Internet, and computer monitors. The goal is that every one of these devices agree on:
And those places outside the triangle on the sRGB chromacity diagram are still all valid colors; your monitor just can't display them.
And the very outside edge of the curve (called the locus) is the location of different pure frequencies of monochromatic light. That is where your pure 445nm monochromatic light source would be: