BookNotesSlidesP-sets Syllabusdraft · v0.2.49.1
◀▲⌂▶
💬Comments welcome. To leave a note, select any text and click the note / highlight button that pops up — or open the panel with the tab at the top-right (‹). Notes are visible only inside our private review group.
💡 In a hurry? Jump to this chapter’s 2 big lessons ↓

4.1 Linear color reproduction and CIE XYZ⧉

A color match reproduces an observer’s responses to light without reproducing its spectrum. For a fixed standard observer, tristimulus coordinates describe these matches with three numbers. The central calculation is linear, but its physical constraints matter: a display can add light from its primaries, not subtract it.

4.1.1 The color reproduction perspective⧉

In principle, measuring color and reproducing it are separate problems. Given light, measurement reports coordinates for its color. Given those coordinates, reproduction builds light on a screen or a page that matches it. You could imagine a camera reporting device-independent measurements to a separate display module, with neither module needing to know how the other works. Much of the notation we actually use comes from treating them together as a reproduction pipeline.

The reason is historical and experimental. Color matching provided a way to measure perceptual color before cone sensitivities could be measured directly. An observer adjusted three fixed primary lights until their mixture matched a test light. The three knob settings were the measurement. These coordinates therefore described amounts of particular reproduction primaries, rather than direct cone responses. Changing the primary lights changed the coordinates of the very same test light. The experiment made measurement possible, but also made the reproduction apparatus part of the measurement convention. Television reinforced the practical importance of a primary-based description: a central engineering task was to get the right picture out of a particular screen.

Metamerism makes this useful. Different spectra can match for the specified observer and conditions. They may cease to match for another observer, or after a change of illumination when the spectra come from reflecting objects. Colorimetry describes the match; it does not by itself predict appearance across different surrounds and adaptation states.

fig-color-reproduction-principle
Figure 4.1.1. Color reproduction end to end, twice over (interactive). Top, a lamp's spectrum is multiplied by the apple's reflectance, and what arrives at the eye is projected onto three cone sensitivities. Three numbers, and every other fact about that spectrum is gone. Bottom, three display primaries, driven by three weights, add to a spectrum that looks nothing like the first one and lands on the same three cone responses. The swatches match; the spectra plainly do not. That is metamerism, and it is the only reason a screen with three primaries can stand in for a world of spectra it cannot emit. Nothing here is drawn by hand: the illuminants are the measured CIE tables at 5 nm, the cone curves come from the 1931 observer, and the weights are found by solving the $3\times3$ system that puts the display's tristimulus on the scene's, so the figure is free to fail and the failures are the lesson. Ask for a color outside the primaries' triangle and a weight goes negative: the screen clips and the match visibly breaks, which is gamut. Turn on a room light and its reflection off the screen adds to what the primaries emit, breaking the match again, which is why color-critical work happens in a dim room. Swap the primaries from an LCD's broad filters to a laser projector's narrow lines and the reachable set grows while the spectrum sent to the eye becomes even less like the scene's: wider gamut, wilder metamer. White balance is the one extra step a camera takes. With it off, the screen reproduces the cone triple the eye actually received, so an apple under tungsten arrives orange; with it on, the triple is adapted to each side's white and the apple looks like an apple. Both are correct answers to different questions, and knowing which one you are asking is most of color management. Exposure is set so the picture fits the screen, so only chromaticity is ever left to fail. Paint the apple on the wheel under the scene: hue is the angle, saturation the radius. It is not a generic color wheel, but a map of what that apple would actually be under the light currently selected, every point computed through the same reflectance-times-illuminant-times-cone-curves path as the rest of the figure, so the wheel itself warms under tungsten and goes strange under the fluorescent tube. The colors on it are also gentler than a display's primaries, which is the truth about surfaces: a real reflectance is broad and smooth, and broad reflectances cannot be very saturated.

XYZ provides a common reference for device characterization and color conversion. The agreement matters as much as the matrix algebra. With a shared reference, a new display can describe its primaries once instead of requiring a separately standardized conversion from every existing camera or working space. Conversion between two linear tristimulus coordinate systems for the same observer is a matrix multiplication. The shared reference lets those conversions be composed. A camera’s three raw channels generally do not span exactly the standard observer’s matching functions, so its color-correction matrix is an approximation fitted to a calibration set. Nonlinear encodings must be decoded before applying linear-light color matrices.

Changing illumination is another limitation. The illumination multiplies reflectance wavelength by wavelength, whereas a three-channel measurement has already discarded most of that spectral information. A three-by-three chromatic-adaptation transform is a useful model of corresponding colors, not a general solution to spectral relighting. Smooth illumination alone does not make it exact.

A typical rendered-image path includes black-level correction, white-balance gains, demosaicking, camera color correction, tone and color rendering, and output encoding. Implementations combine or reorder some stages. XYZ often enters through the calibration that defines the matrices rather than as a separately stored image. To convert between two linear RGB systems, we can compose an RGB-to-XYZ matrix with an XYZ-to-RGB matrix and apply the resulting matrix directly. The intermediate XYZ coordinates define the conversion without needing to be written into an image buffer. This is why XYZ can be central to a system whose working images are all called RGB.

4.1.2 Analysis vs synthesis and non-orthogonality⧉

First imagine three nonoverlapping, flat sensitivity bands. Measuring the power in each band and emitting the same power within that band would reproduce the three measurements. Human cone sensitivities overlap instead: a light chosen to stimulate one cone type also stimulates others. If we use the sensitivity curves themselves as emission spectra, then scale them by the measured responses, measuring the result applies that overlap a second time. The responses generally change, as Figure 4.1.3 shows. We need to account for how every chosen primary stimulates every analysis channel.

The failing construction is short enough to write out. Emit the sensitivity curves weighted by the responses, $\hat{\mathbf e}=C^{\mathsf T}\mathbf r$, and measure the result: the responses come back as $C\hat{\mathbf e}=CC^{\mathsf T}\mathbf r$. The three-by-three matrix $G=CC^{\mathsf T}$ holds the overlap of every pair of curves, and it is the identity only if the curves are orthonormal. For cones it is far from that, above all for L and M, which overlap heavily, so a light that should excite mostly L comes back measured as a large L and M mixture, and a monochromatic test light is rebuilt as a broad, desaturated one (Figure 4.1.3). The correct weights are $G^{-1}\mathbf r$, which is what the dual basis computes, and they include negative entries: to reproduce the test light with these curves as emitters we would have to subtract light, which is the same wall that real primaries hit in the next section.

Sample an incoming spectrum into a vector $\mathbf e$. Let $C$ be a three-by-$N$ analysis matrix, including wavelength-bin weights, and let the columns of $P$ be three sampled display-primary spectra. Measurement and reproduction are

$$\mathbf r=C\mathbf e,\qquad \hat{\mathbf e}=P\mathbf p,\qquad C P\mathbf p=\mathbf r.$$

Thus matching the target requires solving $A\mathbf p=\mathbf r$, where $A=CP$. Each column of $A$ gives the three measured responses to one display primary. If $A$ is invertible, there is a unique algebraic solution. The display can realize it only if every primary weight lies within its allowed range.

💡 Big lesson (L4.2) — color analysis and synthesis require different spectral distributions

Sensitivity curves measure a spectrum; emission primaries construct one. Reusing the sensitivity curves as primaries and the measured responses as weights generally gives the wrong color. Calibrate how each primary stimulates the observer, then solve for its weight.

fig-analysis-vs-synthesis
Figure 4.1.2. Analysis versus synthesis. On the left, analysis: a full spectrum enters and is projected onto three sensor responses (sense → 3 numbers), the arrow pointing inward. On the right, synthesis: three numbers drive a small set of primaries that add up to a reproduced spectrum (reproduce ← few primaries), the arrow pointing outward. The two operations are mirror images, and most color devices are one or the other.
fig-incorrect-synthesis
Figure 4.1.3. Why the cone curves are the wrong synthesis primaries (interactive). Pick a monochromatic test light with the slider. Top (analysis): the three cone responses are the heights of the L, M, S curves at that wavelength. Bottom (incorrect synthesis): rebuild the light by scaling each cone spectrum by its own response and summing them. The sum is a broad, washed-out spectrum, and when it is measured back through the cones its responses are not the originals (they are the original responses multiplied by the cone overlap matrix), so its perceived color is wrong. Reusing the analysis basis for synthesis fails, which is why real display primaries are not the cone sensitivities.
fig-dual-basis-reconstruction
Figure 4.1.4. Reconstruction in a non-orthogonal basis, wrong and right (interactive). Drag the basis vectors $c_1, c_2$ or the target $v$. Left: the naive attempt uses the analysis responses $v\cdot c_i$ directly as coefficients, which only works for an orthonormal basis, so the rebuilt vector misses the target. Right: the correct coefficients come from the dual (reciprocal) basis $c_1^{*}, c_2^{*}$ (defined by $c_i^{*}\!\cdot c_j = \delta_{ij}$); with them $v$ is reconstructed exactly. The dual vectors lean the opposite way, into the negative directions, so recovering the coordinates needs quantities the analysis basis cannot supply, which is exactly why a sensor's cone-like responses cannot double as a display's primaries. Only for an orthonormal basis does the dual coincide with the basis and analysis equal synthesis.

The problem color reproduction actually solves is not quite the textbook one. In linear algebra, reconstruction means rebuilding a vector exactly as a linear combination of basis vectors, so that the result equals the original. Color reproduction asks for less. We do not need the reproduced spectrum to equal the original spectrum, only to produce the same three cone responses, that is, to be a metamer of it. That is a weaker requirement, a match of projections rather than of whole vectors, and it buys a great deal of freedom: the reproduction primaries can be chosen independently of the analysis (cone) vectors, they can be picked to be physically realizable lights, and an in-gamut color can still be matched. Solving the primary-response system gives the coefficients for a given set of primaries; metamerism is what lets us choose those primaries in the first place.

This is where the usual non-orthogonal-basis intuition helps, provided we apply it to the right space. The three primary-response columns need not point along independent cone axes. Solving their linear system compensates for the cross-talk. Merely using a measured cone response as the weight of a similarly shaped emitter applies the cross-talk again. The distinction between taking dot products and solving for synthesis coefficients is familiar from dual bases in linear algebra; here the goal is equality of three measurements, with no requirement to reconstruct the original spectrum.

The algebraic solution can include a negative primary weight. That is a useful coordinate, but a display cannot emit negative light to subtract the unwanted response of another primary. Its physically available mixtures form a restricted set. Metamerism gives us freedom to use a different spectrum for a match; it does not ensure that a particular display's positive mixtures contain a match for every visible color.

The representation labels are a practical type system. A matrix accepting linear RGB cannot be applied directly to encoded RGB merely because both have three components. A luminance and a luma can both be called brightness in conversation while requiring different computations. Before composing two matrices, check that the first one's output has the second one's expected primaries, reference white, normalization, and encoding. The matrix dimensions alone cannot catch these mistakes. This is why color code needs more bookkeeping than an arbitrary three-vector calculation.

Label the representation at each transition. In this part, bare RGB denotes linear values, primes denote a specified nonlinear encoding, and a superscript $\ell$ denotes a specified log encoding. The curve must still be named: a prime does not distinguish sRGB, Rec. 709, or PQ. PQ can encode RGB as well as coordinates used inside ICtCp. A matrix signature states its input and output, for example $M:\mathrm{RGB}_{709}\to\mathrm{XYZ}$. Equal input and output types do not imply an identity operation; exposure scaling is an obvious counterexample.

4.1.3 Color matching and the most standard color space: CIE XYZ⧉

Why measure color through matching experiments rather than directly through cone responses? When the CIE established its 1931 standard, direct measurements of human cone spectral sensitivities were not available. Observers could nevertheless tell when two lights matched. That gave colorimetry an experimental route: define the analysis of a light by measuring its synthesis from adjustable primaries. Metamerism makes this possible because the spectra need not be identical, and the additivity of matches lets the measured coordinates be used for mixtures.

The design of that experiment is why it worked. Psychophysics, putting a number on a private sensation, is slippery: observers disagree, adapt, tire, and shift their answers with the surround and the wording of the task. A matching experiment asks for none of that. It is a null measurement: the observer reports only when the two halves of a field look the same, which people do far more reliably than they rate how different two colors are. Metamerism keeps the answer to three numbers rather than a spectrum, and linearity lets a limited set of measured matches extend to every mixture. The 1931 standard rests on the matching data of Wright and of Guild, about seventeen observers across the two studies, and it still predicts matches for typical observers well enough to anchor color measurement nearly a century later, within the limits of an average observer that the rest of this chapter keeps in view.

In a color-matching experiment, an observer views a test light beside a mixture of three fixed primaries. The primary amounts required for a match define its tristimulus coordinates. Some stimuli cannot be matched with nonnegative amounts: adding a primary to the test side is recorded as a negative amount on the mixture side. Repeating the experiment across wavelength gives the matching functions for those primaries. Wright and Guild used different primaries, and the CIE converted both data sets to three common monochromatic primaries at 700 nm, 546.1 nm and 435.8 nm Fairman, Brill & Hemmendinger 1997. The last two are emission lines of mercury, which any laboratory could reproduce exactly. The red was placed at 700 nm because in that part of the spectrum the hue hardly changes with wavelength, so a small error in setting it hardly changes the match. Spreading the three primaries far apart also keeps them well separated in cone response, the red and green especially, so the matching system is well conditioned.

Audio. Commission Internationale de l’Éclairage, the French name abbreviated CIE.
fig-color-matching-setup
Figure 4.1.5. The color-matching experiment, interactive. A bipartite disk shows a monochromatic test light (left) at a wavelength you choose against an additive mixture of three R, G, B primaries (right); turn the three sliders until the halves match, then submit to pin those three amounts onto the graph below; submit also advances the test wavelength by 50 nm and resets the sliders for the next match. Sweep the wavelength and repeat, and the pinned points, joined into a piecewise-linear curve, trace out the color-matching functions, including the blue-green stretch where the red amount must go negative (you add red to the test side), the impossibility that makes spectral colors unreachable by real primaries. The match works at all because of metamerism: the mixture need only fool the three cones, not equal the test spectrum. (Tick "show computed curves" to overlay the CIE 1931 matching functions, transformed to this figure's sRGB primaries rather than the historical CIE RGB ones.) The disk is drawn on your screen, which clips spectral colors it cannot show, so a visual match here is not a physical color-matching measurement; the numerical error compares the underlying tristimulus values.

The CIE 1931 standard transforms the measured matching functions to imaginary XYZ primaries. These are coordinate axes, not three lamps. The transformation makes all three XYZ matching functions nonnegative and makes $\bar y(\lambda)$ equal to the standard photopic luminous-efficiency function. For a spectral stimulus $E(\lambda)$,

$$\begin{pmatrix}X\\Y\\Z\end{pmatrix} =k\int E(\lambda)\begin{pmatrix}\bar x(\lambda)\\\bar y(\lambda)\\\bar z(\lambda)\end{pmatrix}\,d\lambda.$$

The normalization $k$ determines the scale. For relative tristimulus values, choose it so the reference white has $Y=1$ (or explicitly $100$). For spectral radiance in physical units, the photometric conversion gives $Y$ in cd/m², with a factor approximately 683 lm/W and consistent wavelength units. Relative $Y=1$ is not one cd/m². Neither version of luminance is a full prediction of perceived brightness.

For sampled spectra, include bin widths:

XYZ = [0, 0, 0]
for each wavelength bin i:
    XYZ += k * E[i] * [xbar[i], ybar[i], zbar[i]] * delta_lambda[i]

Use tables for the intended observer and field size. The CIE 1931 two-degree tables specify one standard observer, not every individual’s cone sensitivities.

fig-cie-cmfs
Figure 4.1.6. The CIE 1931 color-matching functions $\bar x(\lambda)$, $\bar y(\lambda)$, $\bar z(\lambda)$. Each curve gives how much of one CIE primary is needed to match a unit of monochromatic light at that wavelength; integrating a spectrum against them yields the tristimulus values $X, Y, Z$. The $\bar y$ curve is, by construction, the luminance-sensitivity curve, so $Y$ is luminance. Note that $\bar x$ dips negative in the cyan region, a fingerprint of non-orthogonal, non-negative color.

LMS coordinates can be defined as a linear transform of XYZ for a chosen colorimetric observer. That does not make modern physiological cone fundamentals an exact transform of the older 1931 observer. For example, the Hunt–Pointer–Estévez transform used in appearance models is

$$\mathbf{LMS}_{\mathrm{HPE}}= \begin{pmatrix}0.38971&0.68898&-0.07868\\-0.22981&1.18340&0.04641\\0&0&1\end{pmatrix} \mathbf{XYZ}.$$

These model coordinates should not be substituted silently for measured cone excitations or a different normalization of cone fundamentals.

💡 Big lesson (L4.3) — linear tristimulus coordinates are a matrix apart

XYZ, a compatible LMS system, and linear RGB are different coordinates for a fixed observer’s three-dimensional color matches. Nonlinear RGB encodings and perceptual spaces add specified nonlinear transforms. A real camera’s raw measurements usually require an approximate color correction; an appearance model also needs viewing conditions.

The negative-primary case is easiest to understand at the apparatus. Suppose a saturated test cannot be matched by adding any nonnegative mixture of the three primary lamps. Move some red primary light to the test side, then adjust green and blue on the matching side until the fields agree. The recorded red coefficient of the original test is negative because that red was added to the opposite side of the equality. No lamp emits negative light. Linearity lets us subtract its contribution algebraically.

Repeat the match with narrow-band test lights across wavelength. The three settings at each wavelength form the color-matching functions. A broad spectrum can then be treated as a sum of these narrow-band contributions, which is why the integral above predicts its tristimulus coordinates. Transforming those coordinates to XYZ changes the coordinate system; it does not require building three imaginary lamps. A monitor illustration can show the controls and equations, but its own primaries limit which test spectra and matches it can physically reproduce.

One might wish that color technology had started with LMS: its axes have a direct interpretation in terms of the receptors. Later measurements of cone photopigments and the development of cone fundamentals made that interpretation much more accessible [@bowmaker-dartnall-1980; @stockman-sharpe-2000]. By then XYZ was already embedded in instruments, specifications, and device characterization. Replacing the common reference would have imposed a compatibility cost on all of them. XYZ also supplies a convenient luminance coordinate and nonnegative matching functions. Its persistence is therefore understandable even though its imaginary primaries and experimental origins make it harder to explain.

Keep the historical argument separate from the observer model. Linear coordinate changes preserve the matches of a fixed observer. A later physiological observer can differ from the 1931 standard; adopting it is not merely renaming the older coordinates. We can explain why XYZ stayed in use without claiming that every modern cone fundamental is an exact transform of the 1931 tables.

4.1.4 Chromaticity diagram⧉

For $X+Y+Z>0$, define

$$x=\frac{X}{X+Y+Z},\qquad y=\frac{Y}{X+Y+Z}.$$

These coordinates discard scale: doubling the light leaves $x,y$ unchanged. Black has undefined chromaticity. Given $xyY$ with $y>0$, recover $X=xY/y$ and $Z=(1-x-y)Y/y$. Thus chromaticity plus luminance specifies the original tristimulus values; chromaticity alone does not.

Monochromatic lights trace the spectral locus. Nonnegative mixtures lie in its convex hull, closed by the line of purples. The reference white is a selected point within this region, not an intrinsic center of the diagram. Euclidean distance in $xy$ is not a perceptual color difference.

fig-chromaticity-diagram
Figure 4.1.7. The CIE $xy$ chromaticity diagram. The horseshoe boundary is the spectral locus (pure monochromatic wavelengths, labeled in nanometers); the straight base is the line of purples. All physically realizable chromaticities lie inside; the white point sits near the center. Brightness has been divided out, so this is a map of hue and purity only (chromaticity).

Geometrically, nonnegative spectra project to a cone of realizable tristimulus values Koenderink, Color for the Sciences. Normalizing by $X+Y+Z$ intersects each nonzero ray with a plane. Normalizing by another linear quantity gives a different cross-section. Although the underlying three-dimensional coordinates are related linearly, the normalized two-dimensional coordinates are related projectively.

fig-chromaticity-3d
Figure 4.1.8. The chromaticity diagram as a flat cross-section of Koenderink's 3-D cone, orbitable. CIE $XYZ$ space is drawn with luminance $Y$ vertical; the spectral locus is the 3-D curve of the color-matching values $(\bar X, \bar Y, \bar Z)$, and rays from the origin $O$ through it sweep out the cone of all realizable colors. A normalization plane slices that cone, and where each ray pierces it is the flattened chromaticity point. With the default plane $X+Y+Z=1$ (the Maxwell triangle) the slice is the familiar bounded, colored horseshoe: brightness divides out and every color lands in a finite region. Tick "normalize by just Y" to slice with the plane $Y=1$ instead, dividing by luminance alone: the coordinates $(X/Y, Z/Y)$ run to infinity as $\bar Y$ falls to zero at the spectral violet and red ends, so that chart is unbounded. That is exactly why the standard normalizes by the sum rather than by $Y$.
fig-lms-horseshoe
Figure 4.1.9. The chromaticity horseshoe, interactive, and where it comes from. It opens on the familiar CIE $xy$ ($XYZ$) view: left, the CIE color-matching functions; right, the spectral locus in $xy$ chromaticity, the curved horseshoe colored by wavelength, its interior filled with the actual color at each chromaticity, and closed along the bottom by the line of purples. Slide the wavelength and the same monochromatic light lights up on both panels. Switch the frame to LMS to swap the color-matching functions for the three cone sensitivity curves and the $xy$ diagram for the cone-response chromaticity ($l = L/(L+M+S)$, $m = M/(L+M+S)$): there the locus is the curved rim of the cone of all spectra (Koenderink), and its curve is literally the shape of the cone sensitivities. The two frames are just a linear transform of each other, so the horseshoe keeps its shape and only the coordinate frame changes. The third frame, MacLeod-Boynton, is the one that looks different, because it divides by something else. Instead of the sum of the three responses it divides by luminance: $l = L/(L+M)$ across, $s = S/(L+M)$ up, on the Smith-Pokorny fundamentals, which are scaled so that $L+M$ is exactly $V(\lambda)$. Every point in that plane is then the same brightness, a horizontal move is a pure trade of $L$ against $M$ and a vertical move is pure $S$, so the two axes are the two chromatic opponent mechanisms rather than an arbitrary pair of coordinates. The locus collapses onto the bottom edge for everything past about 520 nm, which says something real: beyond the green, wavelength barely moves the $S$ cones at all, and hue is carried almost entirely by the $L$ against $M$ balance.

MacLeod–Boynton chromaticity MacLeod & Boynton, cone-excitation chromaticity diagram (1979) uses cone fundamentals scaled so their L and M components sum to the luminance function. It plots $l=L/(L+M)$ and $s=S/(L+M)$. To interpret a horizontal displacement as an L–M trade at fixed luminance, hold the omitted scale $L+M$ fixed. The coordinates themselves do not force all plotted stimuli to have equal luminance, just as $xy$ does not.

A positive XYZ or LMS triple need not be physically realizable: positivity of three projections is weaker than existence of a nonnegative spectrum producing them. Reflectance introduces further constraints, since it must lie between zero and one under a specified illuminant. Do not confuse this surface-color problem with unconstrained emission.

fig-spectrum-for-chromaticity
Figure 4.1.10. What spectrum would it take to make this color, interactive. The previous figure says where the boundary is; this one says what the boundary means. Drag the point anywhere on the diagram, including outside the horseshoe. Inside, the answer is an ordinary reflectance, and the figure shows one: a two-level step, high on a band of wavelengths and low outside it, which is Schrödinger's optimal color whenever the low level comes out at zero. Outside the horseshoe no such spectrum exists, and rather than refuse, the figure shows the one you would need: one of the two levels goes below zero, and so does one of the three cone responses. That is the entire content of the word non-physical, and it is far easier to believe after watching the level cross zero as the point crosses the locus. The search is exact rather than fitted. For a fixed band, the chromaticities reachable by varying the two levels are precisely the straight line through equal-energy white and that band's own chromaticity, drawn dashed through the point, so finding the spectrum means finding the band whose line runs through the target and then solving for the levels. Every point on the plane lies on some such line, which is why the figure always has an answer; whether that answer is non-negative is exactly the question of whether the point is inside the horseshoe. The vertical scale puts the larger level at 1, so what changes as you drag is the sign, not the size.

Why divide by the sum rather than by luminance alone? Dividing by $Y$ is an appealing choice when the goal is to separate luminance from color, but coordinates such as $X/Y$ can become very large when $Y$ is small compared with another component. By dividing nonnegative XYZ coordinates by their sum, we instead put each normalized component between zero and one and make the three sum to one. The resulting diagram is bounded. This is a practical benefit of the chosen normalization, not a statement that its distances are perceptually uniform. Figure 4.1.8 makes the choice visible as a change of slicing plane.

The curved locus also has a physical origin. Sweep a monochromatic test through wavelength. At each setting its position comes from the three matching-function values at that wavelength, normalized by their sum. Those values vary together along the sensitivity curves, so the plotted point follows a curve rather than the sides of a triangle. Mixtures fill the convex region determined by that locus. The diagram's outline reflects the observer's spectral sensitivities; it is not an arbitrary shape chosen for a plotting convention.

4.1.5 Keeping track of what the numbers mean⧉

An array needs more than a label saying “RGB.” Record its primaries, transfer function, white reference, numeric range, and whether it represents scene light or a rendered image. Relative XYZ also needs its normalization. A camera-native RGB array needs a camera characterization.

Before a transform, check these assumptions against its input. A matrix defined for linear RGB cannot consume sRGB-encoded samples directly. Assigning a profile declares how existing numbers should be interpreted; converting to another profile changes the numbers to preserve the intended color. White adaptation changes a reference condition and must not be applied twice.

I find this bookkeeping more troublesome than most of the individual equations. Several independent choices travel under one name such as “sRGB,” and applications often hide which choices they made. Explicit metadata and a few labeled intermediate arrays are more useful than guessing from whether the picture looks plausible.

Treat a color transform like a units check. A matrix labeled as taking linear Rec. 709 RGB to XYZ cannot be fed the encoded samples read from an sRGB image. A value labeled Y′ is luma, so substituting it for linear luminance in a physical-light calculation changes the problem. A transform expecting a D65 reference cannot silently be given D50-relative coordinates. Writing the encoding and white reference next to an intermediate array makes these errors visible before the picture is displayed.

There are two kinds of difficulty here. Some come from the measurement: three responses do not determine a spectrum, and the same surface sends different light under different illumination. Others come from conventions maintained across decades, such as print workflows using D50, common display spaces using D65, and the name sRGB covering both primaries and a transfer function. Separating the physical ambiguity from the bookkeeping helps identify what a better calibration can solve and what merely needs an explicit conversion.

A cleaner interface would separate the measurement of the incoming light from the choice of how a particular device should reproduce it. The measurement would identify its observer and normalization; the rendering would specify the viewing conditions, output device, and intended appearance. Color management tries to provide this separation through documented profiles and a common connection space (Chapter 4.8, Recap: the full color pipeline, color management and ICC). It has to work with existing representations, though. A name such as sRGB specifies primaries, a white reference, and an encoding together. Separating those choices remains work for the programmer. The type annotations make that separation explicit on the page.

4.1.6 Linear RGB⧉

LMS and XYZ are analysis spectra, built to measure color. To store and reproduce it we use the RGB family, and the standard member is sRGB (Stokes et al. 1996 (sRGB)), whose primaries are the Rec. 709 primaries under the D65 white point. In linear light, sRGB and XYZ are one $3\times3$ apart. The forward matrix takes a measured color into linear sRGB,

$$ M : \mathrm{XYZ}_{[\mathrm{D65}]} \to \mathrm{RGB}_{709}, \qquad \begin{pmatrix} R \\ G \\ B \end{pmatrix} = \begin{pmatrix} \phantom{-}3.2406 & -1.5372 & -0.4986 \\ -0.9689 & \phantom{-}1.8758 & \phantom{-}0.0415 \\ \phantom{-}0.0557 & -0.2040 & \phantom{-}1.0570 \end{pmatrix} \begin{pmatrix} X \\ Y \\ Z \end{pmatrix}, $$

and its inverse recovers XYZ,

$$ M^{-1} : \mathrm{RGB}_{709} \to \mathrm{XYZ}_{[\mathrm{D65}]}, \qquad \begin{pmatrix} X \\ Y \\ Z \end{pmatrix} = \begin{pmatrix} 0.4124 & 0.3576 & 0.1805 \\ 0.2126 & 0.7152 & 0.0722 \\ 0.0193 & 0.1192 & 0.9505 \end{pmatrix} \begin{pmatrix} R \\ G \\ B \end{pmatrix}. $$

The coefficients shown are rounded. Apply them to linear values; a typical sRGB file must first be decoded. The middle row of the RGB-to-XYZ matrix gives relative luminance. Applying those weights to encoded components gives luma, which is neither luminance nor generally the encoding of luminance.

Negative RGB components indicate a target outside the positive cone spanned by these primaries. Components above one exceed the chosen reference range; they can represent greater intensity at an otherwise reproducible chromaticity. Floating-point scene-linear images often retain such values. Clipping to $[0,1]$ is an output decision that can change hue and discard highlight information.

Recap: big lessons of this chapter

💡 Big lesson (L4.2) — color analysis and synthesis require different spectral distributions

Sensitivity curves measure a spectrum; emission primaries construct one. Reusing the sensitivity curves as primaries and the measured responses as weights generally gives the wrong color. Calibrate how each primary stimulates the observer, then solve for its weight.

fig-incorrect-synthesis
Figure 4.1.3 (reproduced). Why the cone curves are the wrong synthesis primaries (interactive). Pick a monochromatic test light with the slider. Top (analysis): the three cone responses are the heights of the L, M, S curves at that wavelength. Bottom (incorrect synthesis): rebuild the light by scaling each cone spectrum by its own response and summing them. The sum is a broad, washed-out spectrum, and when it is measured back through the cones its responses are not the originals (they are the original responses multiplied by the cone overlap matrix), so its perceived color is wrong. Reusing the analysis basis for synthesis fails, which is why real display primaries are not the cone sensitivities.
💡 Big lesson (L4.3) — linear tristimulus coordinates are a matrix apart

XYZ, a compatible LMS system, and linear RGB are different coordinates for a fixed observer’s three-dimensional color matches. Nonlinear RGB encodings and perceptual spaces add specified nonlinear transforms. A real camera’s raw measurements usually require an approximate color correction; an appearance model also needs viewing conditions.