Color Theory
Kurt Akeley
CS248 Lecture 17
27 November 2007
http://graphics.stanford.edu/courses/cs248-07/
CS248 Lecture 17 Kurt Akeley, Fall 2007
Introduction
Difficulties:
I’m learning this too
Terminology is used carelessly
There are lots of standards CIE 1931, CIE 1964, Vos 1976, SMJ 1993, …
Caveats:
Not comprehensive Lots of CIE content, nothing on HSV or video
Units may be off (or missing all together)
Derived plots may differ slightly from standards
…
CS248 Lecture 17 Kurt Akeley, Fall 2007
Human photoreceptors
www.stat.auckland.ac.nz/~ihaka/787/lectures-vision.pdf
Monochromatic scotopic vision
(low light levels)
Chromatic photopic vision
(high light levels)
There is a view direction (despite
what I told you). It doesn’t affect the projection, but it does affect the nature of the
receptor array.
CS248 Lecture 17 Kurt Akeley, Fall 2007
Humans are trichromats
Spectral sensitivities of human cones
Stockman, MacLeod, and JohnsonJournal of the Optical Society of
AmericaVolume 10, Number 12, December
1993Table 8
Monochromatic
stimulus
Determined by chemistry and
retinal coverage
LM
S
Monochromat: Horshoe crabs
Dichromat: dogsTrichromat: people, most
camerasTetrachromat: fancy
camerasPentachromat: Mallard
ducks[L M S] = EvalSmjSRF(lambda);[0.0197 0.0372 0.0104] =
EvalSmjSRF(470);All three contributions are
non-zero (the plots overlap)!
CS248 Lecture 17 Kurt Akeley, Fall 2007
Luminosity function
Sum of L, M, and S responses for
photopic vision ?(FvD pp. 576)
CS248 Lecture 17 Kurt Akeley, Fall 2007
Comparison of luminosity functions
Derived from SMJ spectral-response
data by simple addition
From Wikipedia
Yes, the units are different. We are interested in the
shapes.
CS248 Lecture 17 Kurt Akeley, Fall 2007
Luminous efficacy (and efficiency)
How much of the radiated energy (efficacy/efficiency) or wall-socket energy (overall efficacy/efficiency) of a light source is usable for vision?
Integrate the product of the luminosity function with the spectrum of the light source.
Source: Wikipedia
CS248 Lecture 17 Kurt Akeley, Fall 2007
Metamers
Response is linear
So response to an energy spectrum is the sum of the responses to the individual spectral components
Same integration as for luminous efficiency, but done separately for L, M, and S, rather than for their sum
Many different spectra will produce the same L,M,S response
These spectra are metamers
Metamers are form of aliasing: undersampling (only three cone types) causes different signals to appear equivalent
This aliasing is very convenient …
CS248 Lecture 17 Kurt Akeley, Fall 2007
CIE 1931 RGB primaries
λB=435 nm
λG=546 nm
λR=700 nm[L M S] = EvalSmjSRF(700)*Sr + EvalSmjSRF(546)*Sg + EvalSmjSRF(435)*Sb);
M = [ EvalSmjSRF(700) EvalSmjSRF(546) EvalSmjSRF(435) ]; R = 1; G = 1; B = 1;
[L M S] = [R G B] * M;
CS248 Lecture 17 Kurt Akeley, Fall 2007
RGB color-matching function
M = [ EvalSmjSRF(700) EvalSmjSRF(546) EvalSmjSRF(435) ]; R = 1; G = 1; B = 1;
[L M S] = [R G B] * M;
[R G B] = [L M S] * Minv;
CMF(lambda) = EvalSmjSRF(lambda) * Minv;
What proportion of the R, G, and B primaries is required to match a spectral color?
CS248 Lecture 17 Kurt Akeley, Fall 2007
RGB color-matching function
Primary amplitudes are adjusted to give
equal areas under all three color-matching
curves
Oops, what is a negative
primary contribution?
CS248 Lecture 17 Kurt Akeley, Fall 2007
RGB color-matching function
W = DomainSmjSRF(1);len = length(W);% compute M assuming equal-intensity primariesM = [ EvalSmjSRF(Rnm) * 1 EvalSmjSRF(Gnm) * 1 EvalSmjSRF(Bnm) * 1];Minv = inv(M);% integrate the color-matching functionCMFsum = [0 0 0];for n = 1 : len CMFsum = CMFsum + EvalSmjSRF(W(n)) * Minv;end% recompute M such that the color-matching curves have equal integrals% this amounts to scaling the primary intensities by Rs, Gs, and BsRs = CMFsum(1) / CMFsum(3);Gs = CMFsum(2) / CMFsum(3);Bs = 1;M = [ EvalSmjSRF(Rnm) * Rs EvalSmjSRF(Gnm) * Gs EvalSmjSRF(Bnm) * Bs];Minv = inv(M);% compute the color-matching functionCMF = zeros(len, 3);for n = 1 : len CMF(n,:) = EvalSmjSRF(W(n)) * Minv;end
[390 391 392 … 729 730]
CS248 Lecture 17 Kurt Akeley, Fall 2007
Negative primaries
Can’t add a negative primary amount
So a negative match adds the (opposite of) the negative amount to the source being matched, rather than to the matching light
Sensible but awkward
CS248 Lecture 17 Kurt Akeley, Fall 2007
CIE 1931 XYZ primaries
Derived by linear transformation from the RGB primaries:
The matrix coefficients were (obviously) chosen carefully
We’ll see some of the desirable properties in later slides
The XYZ primaries are imaginary
They do not correspond directly to amounts of light
But they are very useful …
[ ] [ ]0.49 0.17697 0.00
10.31 0.81240 0.01
0.176970.20 0.01063 0.99
X Y Z R G B
é ùê úê ú= × ×ê úê úë û
CS248 Lecture 17 Kurt Akeley, Fall 2007
CIE 1931 XYZ color-matching function
Intended property:
Y = luminosity
Intended property:
non-negative
CS248 Lecture 17 Kurt Akeley, Fall 2007
A special metamer
400 nm
700 nm
Energy density
wd
e1
e2
Dominant wavelength = wd
Excitation purity = (e2-e1) / (e2+e1)
Luminance is related to the integration of the spectrum (as we saw before)
These determine
chromaticity
CS248 Lecture 17 Kurt Akeley, Fall 2007
XYZ chromaticity
Rescale X, Y, and Z to remove luminance, leaving chromaticity:
Because the sum of the chromaticity values x, y, and z is always 1.0, a plot of any two of them loses no information
Such a plot is a chromaticity plot
X Y Z
x y zX Y Z X Y Z X Y Z
= = =+ + + + + +
CS248 Lecture 17 Kurt Akeley, Fall 2007
xz chromaticity
You’ve never seen this plot, but it is
perfectly valid. The standard plots the x and y chromaticity
values.
CS248 Lecture 17 Kurt Akeley, Fall 2007
CIE 1931 xy chromaticity (derived from SMJ data)
Intended property:
non-negative
Intended property:
white point at(1/3, 1/3, 1/3)
Intended property:
fitted to edge of right triangle
CS248 Lecture 17 Kurt Akeley, Fall 2007
CIE 1931 xy chromaticity (actual CIE standard)
Image from www.wikipedia.com
Pure (saturated) spectral colors around the edge of the
plot
Less pure (desaturated) colors in the interior of
the plot
White at the centroid of the plot
(1/3, 1/3)
Are the colors correct ?
CS248 Lecture 17 Kurt Akeley, Fall 2007
CIE 1931 rg chromaticity (derived from SMJ data)
Intended property:
white point at(1/3, 1/3, 1/3)
CS248 Lecture 17 Kurt Akeley, Fall 2007
rb chromaticity (derived from SMJ data)
Intended property:
white point at(1/3, 1/3, 1/3)
CS248 Lecture 17 Kurt Akeley, Fall 2007
Gamut
Gamut is the chromaticities that can be generated by a set of primaries
Because everything we’ve done is linear, interpolation between chromaticities on a chromaticity plot is also linear
Thus the gamut is the convex hull of the primary chromaticities
What is the gamut of the CIE 1931 primaries?
CS248 Lecture 17 Kurt Akeley, Fall 2007
CIE 1931 RGB gamut
R = 700 nm
G = 546 nm
B = 438 nm
All dominant wavelengths can be
reproduced, but many cannot reach full
saturation.
No finite set of primaries can
reproduce the entire gamut. But more
primaries do a better job.
So the colors on the xy chromaticity diagram
cannot be correct, because no display
can accurately reproduce them!
CS248 Lecture 17 Kurt Akeley, Fall 2007
MATLAB code
RGBr = EvalSmjSRF(Rnm) * Minv;RGBg = EvalSmjSRF(Gnm) * Minv;RGBb = EvalSmjSRF(Bnm) * Minv;XYZr = RGBr * CieM;XYZg = RGBg * CieM;XYZb = RGBb * CieM;xyzr = XYZr / (XYZr(1) + XYZr(2) + XYZr(3));xyzg = XYZg / (XYZg(1) + XYZg(2) + XYZg(3));xyzb = XYZb / (XYZb(1) + XYZb(2) + XYZb(3));
…
plot([xyzr(1) xyzg(1) xyzb(1) xyzr(1)], ... [xyzr(2) xyzg(2) xyzb(2) xyzr(2)], ... ‘c.-', 'linewidth', lw);
CS248 Lecture 17 Kurt Akeley, Fall 2007
Short-persistence phosphor CRT gamut
CS248 Lecture 17 Kurt Akeley, Fall 2007
Long-persistence phosphor CRT gamut
CS248 Lecture 17 Kurt Akeley, Fall 2007
LCD projector gamut (hypothetical)
CS248 Lecture 17 Kurt Akeley, Fall 2007
MATLAB and dichroic filter source
RGBr = [0 0 0];RGBg = [0 0 0];RGBb = [0 0 0];for n = 1 : len TF = EvalDichroicRgbTF(W(n)); RGBr = RGBr + (TF(1) .* CMF(n,:)); RGBg = RGBg + (TF(2) .* CMF(n,:)); RGBb = RGBb + (TF(3) .* CMF(n,:));endXYZr = RGBr * CieM;XYZg = RGBg * CieM;XYZb = RGBb * CieM;xyzr = XYZr / (XYZr(1) + XYZr(2) + XYZr(3));xyzg = XYZg / (XYZg(1) + XYZg(2) + XYZg(3));xyzb = XYZb / (XYZb(1) + XYZb(2) + XYZb(3));
…
plot([xyzr(1) xyzg(1) xyzb(1) xyzr(1)], ... [xyzr(2) xyzg(2) xyzb(2) xyzr(2)], ... ‘c.-', 'linewidth', lw);
Image from www.edmundoptics.com
Realistic primaries have wide
spectrums. Why?
Assumes projector light
has flat spectrum (wrong)
CS248 Lecture 17 Kurt Akeley, Fall 2007
Subtractive color
We have been adding primaries with spectra that are (almost) mutually exclusive
This works for displays, but not for printing It could work for printing, if dye were reflective and
could be placed in very small, non-overlapping, regions
But (I guess) this doesn’t work well, so instead ink is designed to block light, and to be mixed on the surface of a white page
Typical (additive) RGB filters have transmission functions like these:
What would you expect the transmission functions of subtractive filters to look like?
CS248 Lecture 17 Kurt Akeley, Fall 2007
Subtractive color
Image from www.edmundoptics.com
CS248 Lecture 17 Kurt Akeley, Fall 2007
Additive and subtractive primaries
The statement that “the additive primaries are red, green, and blue” is clearly incorrect
Any set of three non-colinear primaries yields a gamut
Primaries that appear red, green, and blue are a good choice, but not the only choice
Additional (non-colinear) primaries are always better
Likewise, the statement that “the subtractive primaries are magenta, cyan, and yellow” is also incorrect, for the same reasons
Subtractive primaries must collectively block the entire visible spectrum, but many sets of blockers that do so are acceptable “primaries”
The use of black ink (the k in cmyk) is a good example
Modern ink-jet printers often have 6 or more ink colors
CS248 Lecture 17 Kurt Akeley, Fall 2007
Final thoughts
CIE RGB and CIE XYZ are color spaces
Many other color spaces, with different strengths and weaknesses, are possible
Refer to Marc Levoy’s 2006 CS248 lecture notes for many details: http://graphics.stanford.edu/courses/cs248-06/color/
color1.html
CS248 Lecture 17 Kurt Akeley, Fall 2007
Summary
Perceived color is the ratio of (linear) L, M, and S stimulation
It is not possible to distinguish between “metamers”
Three degrees of freedom need for (at least) three primaries
Everything derives from the human spectral-response function
Luminosity function (I think)
Reasonable choices for primaries
Color-matching functions (RGB and XYZ)
Chromaticity diagrams (rg and xy)
Three primaries cannot reproduce the entire human gamut
Use chromaticity diagram to understand what can be reproduced
Subtractive colors
Are a convenient fiction (like ‘holes’ in semiconductor theory)
The true color arithmetic is unchanged
CS248 Lecture 17 Kurt Akeley, Fall 2007
Assignments
Next lecture: Some combination of lighting theory and z-buffer theory, TBD (Thursday 29 November)
Reading assignment: none (work on your projects)
CS248 Lecture 17 Kurt Akeley, Fall 2007
End