What is wrong with this?The above is supposed to show, as accurately as possible on a computer screen, the colours of the visible spectrum as a function of wavelength in nanometers. What is wrong with it? The problem is that computer monitors cannot show monochromatic colours as saturated as the eye is able to perceive them. Disco purple, at the shortest monochromatic wavelengths, probably shows up on the screen as wilting violet, while crimson red, at the longest monochromatic wavelengths, appears pinkish. How do you plot a spectrum of monochromatic colours as accurately as possible on a computer screen? Set saturation to \(1\), and run hue from \(-0.046\) (i.e. \(0.954\), about right for crimson red) to \(0.753\) (about right for disco purple), right? Actually it’s more complicated if you want to do it right. The following four steps describe what to do. Step 1: Define the spectrumAs you undoubtedly know, the eye perceives colour through three types of cone on the retina. As a result, it is possible to define any colour, any mixture of visible wavelengths, using 3 coordinates.By convention of the Commission Internationale de l’Éclairage (CIE), colours are defined by their ‘tristimulus’ coordinates \(X\), \(Y\), \(Z\). The coordinates are linear measures of light power, so that the coordinates of any sum of colours is the sum of the coordinates of the colours. The middle coordinate, \(Y\), called the ‘luminance’, is the light power weighted by the CIE 1924 Photopic Luminosity Function, a certain spectral sensitivity function characteristic of human vision. The luminance \(Y\) can be regarded as a measure of perceived brightness, with the proviso that it varies linearly with power, whereas the eye responds nonlinearly with power.
The colour of a colour, without reference to its total power,
is conventionally described by
its ‘chromaticity’ coordinates \(x\), \(y\), defined by
\begin{equation}
\label{eq1}
x \equiv {X \over X + Y + Z}
\ , \quad
y \equiv {Y \over X + Y + Z}
\ .
\end{equation}
A table of the tristimulus coordinates \(X\), \(Y\), \(Z\) for monochromatic light every 1 nm from 360 nm to 830 nm is available from the Color and Vision Research Laboratory. There are two sets of files, the original 1931 set, based on experiments that involved people matching colours in a split \(2^\circ\) field, about the size of the cone-rich fovea at the center of the retina, and a supplementary 1964 set, for a \(10^\circ\) field, which gives greater weight to rods. The \(2^\circ\) tristimuli are appropriate for normal colour vision at daylight levels of illumination, while the \(10^\circ\) tristimuli are more appropriate for dark-adapted vision. The spectrum at the top of this page used the \(2^\circ\) field tristimuli. Step 2: Define the characteristics of the monitorThe characteristics of a colour monitor are determined by the the colours of its guns, its red, green, and blue primaries. Measured on a linear scale of light power, the monitor’s primaries are denoted \(R\), \(G\), and \(B\). It is important to distinguish these linear measures of colour from the nonlinear measures \(R^\prime\), \(G^\prime\), \(B^\prime\) that are specified to the computer’s colour tables. More on the latter in Step 4 below.The colour of each primary is specified by its tristimulus coordinates. For example, the colour of the \(R\) gun is specified by \(X_R\) , \(Y_R\) , \(Z_R\) . Given these coordinates, the tristimulus coordinates \(X\), \(Y\), \(Z\) of any combination colour \(R\), \(G\), \(B\) are given by the linear transformation \begin{equation} \label{eq2} \left( \begin{array}{c} X \\ Y \\ Z \end{array} \right) = \left( \begin{array}{ccc} X_R & X_G & X_B \\ Y_R & Y_G & Y_B \\ Z_R & Z_G & Z_B \end{array} \right) \left( \begin{array}{c} R \\ G \\ B \end{array} \right) \ . \end{equation} For example, the monitor’s colour white, \(W\), is defined by all guns firing on full, \(R_W = G_W\ = B_W\ = 1\), so that \(X_W = X_R + X_G + X_B\), and similarly for \(Y_W\) and \(Z_W\). Conversely, the \(R\), \(G\), \(B\) coordinates of any colour \(X\), \(Y\), \(Z\) are given by the inverse of the matrix transformation (\(\ref{eq2}\)), Hello \begin{equation} \label{eq3} \left( \begin{array}{c} R \\ G \\ B \end{array} \right) = \left( \begin{array}{ccc} X_R & Y_R & Z_R \\ X_G & Y_G & Z_G \\ X_B & Y_B & Z_B \end{array} \right) \left( \begin{array}{c} X \\ Y \\ Z \end{array} \right) = \left( \begin{array}{ccc} X_R & X_G & X_B \\ Y_R & Y_G & Y_B \\ Z_R & Z_G & Z_B \end{array} \right)^{-1} \left( \begin{array}{c} X \\ Y \\ Z \end{array} \right) \ . \end{equation} Usually, the colour properties of a monitor are specified not in terms of the tristimuli of its primaries, as above, but rather in terms of the chromaticities \(x_R\), \(y_R\), \(x_G\), \(y_G\), \(x_B\), \(y_B\), of the primaries, together with the chromaticity \(x_W\), \(y_W\) of the white point. Conventionally, the luminance of white is normalized to one, \(Y_W = 1\). The 6 primary chromaticities, the 2 white chromaticities, and the white luminance together constitute 9 quantities, precisely sufficient to specify the 9 tristimulus coordinates of the \(R\), \(G\), \(B\) primaries.
What primary and white chromaticities should one assume? Item 45 of the Color FAQ recommends using the CIE D65 ‘daylight’ white point \begin{equation} \label{eq4} x_W = 0.3127 \ , \quad y_W = 0.3290 \ , \end{equation} and primary chromaticities from Rec. 709 (ITU-R Recommendation BT. 709, 1990, “Basic Parameter Values for the HDTV Standard for the Studio and for International Programme Exchange”, formerly CCIR Rec. 709), \begin{equation} \label{eq5} \left( \begin{array}{ccc} x_R & x_G & x_B \\ y_R & y_G & y_B \end{array} \right) = \left( \begin{array}{ccc} 0.64 & 0.30 & 0.15 \\ 0.33 & 0.60 & 0.06 \end{array} \right) \ . \end{equation} The spectrum at the top of this page, and the chromaticity diagram just below, use these recommended values. Step 3: Transform from \(XYZ\) to \(RGB\)Given the tristimuli coordinates \(X\), \(Y\), \(Z\) of any colour, such as those for monochromatic colours specified in the CIE \(2^\circ\) tables, and the characteristics of the colour monitor as described in Step 2, the corresponding \(R\), \(G\), \(B\) coordinates follow from equation (\(\ref{eq3}\)).Often one or two (never three) of the \(R\), \(G\), \(B\) coordinates will turn out negative. This means that the colour lies outside the ‘gamut’ of colours that the monitor can reproduce. For example, every monochromatic colour is out of gamut. On the chromaticity diagram, the gamut forms a triangle with the monitor’s primaries at its vertices, as in the diagram on the right, constructed using a corrected version of John Walker’s cietoppm utility. The blackbody trajectory on this chromaticity diagram is discussed on the What colour is the Sun? page. Compare this diagram to the chromaticity diagram with respect to the fundamental primaries on the Primary Colours page. The standard way to fix out-of-gamut colours is to add white — equal parts of \(R\), \(G\), and \(B\) — just enough to make all components positive, so bringing the colour to the border of the gamut. That is, add \(- \min(R,G,B,0)\) to each of \(R\), \(G\), and \(B\). It is this adding of white that causes disco purple and crimson red to appear palid in the spectrum at the top of this page. At this point you are free to multiply the \(R\), \(G\), and \(B\) values of your entire picture by some overall factor, to achieve the desired overall level of brightness. If any of the \(R\), \(G\), or \(B\) values exceed the permitted maximum (typically \(1\), or \(255\)), then obviously you will have to scale those values back to the maximum. Step 4: Do a gamma correctionThe colour guns on monitors respond nonlinearly to their inputs. As Charles Poynton emphasizes in Gamma FAQ, this is a feature, not a bug. The nonlinearity roughly matches the nonlinear response of the human eye, and allows a broader dynamic range of perceived brightnesses to be coded with fewer bits.The transformation from linear coordinates \(R\), \(G\), and \(B\) to nonlinear coordinates \(R\), \(G\), and \(B\), or vice versa, is called ‘gamma-correction’. It is the latter nonlinear coordinates \(R\), \(G\), \(B\) that are specified in software, such as in HTML, PostScript, xv, and so on. Item 45 of the Color FAQ recommends again following Rec. 709, which specifies a gamma-correction (see Item 6 of the Gamma FAQ) \begin{equation} \label{eq6} R^\prime = \left\{ \begin{array}{ll} 4.5 R & ( R \leq 0.018 ) \ , \\ 1.099 R^{0.45} - 0.099 & ( R > 0.018 ) \ . \end{array} \right. \end{equation} and similarly for each of \(G\) and \(B\). Equation (\(\ref{eq6}\)) assumes that \(R\), \(G\), \(B\) are scaled so that they run from a minimum of \(0\) to a maximum of \(1\). The correction is a power law except for the linear ramp near black. The reciprocal of the index of the power law is the ‘gamma’ of the transformation \begin{equation} \label{eq7} \gamma = {1 \over 0.45} \approx 2.2 \ . \end{equation} The spectrum at the top of this page, and the chromaticity diagram above, use the recommended gamma-correction (\(\ref{eq6}\)). Sources
|
Updated 18 Nov 1999