# How to determine RGB values given a display spectral response curve?

I am reading Physically Based Rendering section 2.2.2 on RGB color.

I am trying to understand how, given a display spectral response curves for rgb intensities, we can choose the intensities so that the display will emit an equivalent spectrum (a CIE xyz metamer)

It is my understanding that the following section tries to explain exactly that.

Given an (x,y,z) representation of an SPD, we can convert it to corresponding RGB coefficients, given the choice of a particular set of SPDs that define red, green, and blue for a display of interest. Given the spectral response curves R(lambda), G(lambda), and B(lambda), for a particular display, RGB coefficients can be computed by integrating the response curves with the SPD S(lambda) and using the tristimulus theory of color perception:

$$r = \int R(\lambda) S(\lambda) d\lambda$$

I can't understand this formula. Why it is considered correct? Why choosing r this way makes the display emit the correct / equivalent SPD?

Can someone break it down for me?

First off let me say that the first line in 5.2.2 is wrong or misleading when it says "spectral response curves, one for each of red, green, and blue, as emitted by the display". A "spectral response curve" is the property of a sensor, such as the human eye or a camera sensor, which responds to light. For an emitter of light such as a display, the equivalent is an "emission curve" or more commonly "spectral power distribution (SPD)".

The XYZ values are the device independent specification of a colour, and can be calculated using the specific spectral response curves called colour matching functions (CMFs). The XYZ system is defined that any real colour will have X, Y and Z values in the range of 0 to 1, though not all combinations of values in that range are physically possible colours.

The CMFs are available from the Colour and Vision Research laboratory here http://www.cvrl.org/, under the "CMFs" link. They look like this, with the X CMF displayed in red, Y displayed in green and Z displayed in blue.

You can combine any SPD with these CMFs to get the XYZ values of that SPD, that is what the function is doing. By multiplyng the amount of each wavelength emitted by one of the RGB emitters in the display with the response strength of the CMF and summing them together, you calculate the total response to that emitter. By doing this for each of the X, Y and Z CMFs you get the XYZ value of the colour of that emitter.

For sRGB monitors these should be approximately (in XYZ order):
R: (0.4124564 0.2126729 0.0193339)
G: (0.3575761 0.7151522 0.1191920)
B: (0.1804375 0.0721750 0.9503041)

If you look at the values in the RGBToXYZ function you will see these approximate values in the matrix, but arranged vertically rather than horizontally.

Many different SPDs could give these same XYZ values, but any SPD with the same XYZ values should look the same to the human eye, so it does not matter that different monitors have different SPDs, as long as they have the same XYZ values.

Once you have these values for the monitor, you can convert any colour's XYZ values to the required RGB values using the XYZToRGB function. If all three values are in the range 0 to 1, you can display the colour on the monitor. If any value is outside of the range of 0 to 1, then the colour is outside of the gamut of the monitor, and cannot be displayed accurately on that monitor.

The reason for doing this is to convert an SPD to three values in RGB or XYZ, which is much easier to manage than the full detail of the SPD, and in most cases is an adequate description of the SPD. You can just sum the XYZ values for each SPD multiplied by the linear RGB value for each to get the resulting total XYZ, which is much simpler than calculating the combined SPD and then calculating the XYZ of the combined SPD, but will give the same answer.

One last note, throughout the article you refer to and this answer, RGB values are given as LINEAR RGB values. In practice RGB values are usually given as GAMMA-ENCODED RGB values for efficiency, so there is an additional step you would need to do in practice to convert the values.

I'll try my best to give an overview of the subject, and english is not my first language so feel free to ask more detailed information in comments etc.

Here are some terms, light is an electro magnetic radiation. When the power of this radiation falls between a certain wave length, it becomes visible for human beings. S is the function that takes wave length value as input and gives a power value as output and is called a s(pectral) p(ower) d(istribution).

Color on the other hand means different things to different people. We can define color based on our perception of it, or based on the measured spectral power distribution, based on the average physical capacity of human eye etc.

The thing is spectral distributions change over time constantly, but the color does not change at the same speed. This means that variations in the spectral distribution does not map to color one to one, which shows that there must be a transformation happening between what we perceive as color and what we measure as spectral distribution.

Now the needs for an accurate and standardised representation of color was quite important for daily life (think of colors around road signs, lamps, etc), the CIE defined its trichomatic system for this purpose. The main idea behind the trichromatic system was that given a carefully chosen three reference spectral distribution, we can represent all of the perceivable colors by mixing these three spds.

Notice that I did two things over there. I passed from mixing spds, which should produce an spd at the end, to color values which are generally represented with trichromatic system, and I added perceived. The last one is to signal that this is an experimental procedure, that is people did a lot of experiments to come up to this idea of mixing reference spds.

How do we arrive from mixing spds which should produce an spd to a color value in rgb ? Simple by summing all the power values of the spd resulting from the mix. The mix is $$R(\lambda)S(\lambda)$$ part where R is the reference spd and S is any given spd. $$\int$$ indicates that we are summing the resulting multiplication. $$\lambda$$ is the wave length.

A great reference on the subject is McCluney 1994, Introduction to Radiometry, chapter 11. Read through 11.2 and then 11.4, that should clarify anything and everything with respect to spds and their transformation to trichromatic values

• "spectral distributions change over time constantly, but the color does not change at the same speed." Not sure where this is coming from, but it doesn't have anything to do with change over time - it's just that our eyes have just 3 types of cones and so the infinite-dimensional physical spectra get projected down to a 3-dimensional color space. Jan 8, 2021 at 5:24
• "spd change over time..." that was my, not so accurate way of describing metamerism of the eye, that is it perceives identical color with different spectral distributions. As for 3 cones, McCluney says on page 345-346 that spectral responses of the three cones largely overlap so it was not use full for a color specification. I really like your blog by the way. Jan 8, 2021 at 7:58