370 likes | 646 Views
Color Theory. Kurt Akeley CS248 Lecture 17 27 November 2007 http://graphics.stanford.edu/courses/cs248-07/. 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
E N D
Color Theory Kurt Akeley CS248 Lecture 17 27 November 2007 http://graphics.stanford.edu/courses/cs248-07/
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 • …
Human photoreceptors 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. www.stat.auckland.ac.nz/~ihaka/787/lectures-vision.pdf
Monochromaticstimulus Humans are trichromats Spectral sensitivities of human conesStockman, MacLeod, and JohnsonJournal of the Optical Society of AmericaVolume 10, Number 12, December 1993Table 8 M L Determined by chemistry and retinal coverage Monochromat: Horshoe crabsDichromat: 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)! S
Luminosity function Sum of L, M, and S responses for photopic vision ? (FvD pp. 576)
Comparison of luminosity functions Yes, the units are different. We are interested in the shapes. Derived from SMJ spectral-response data by simple addition From Wikipedia
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
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 …
CIE 1931 RGB primaries [L M S] = EvalSmjSRF(700)*Sr + EvalSmjSRF(546)*Sg + EvalSmjSRF(435)*Sb); λR=700 nm M = [ EvalSmjSRF(700) EvalSmjSRF(546) EvalSmjSRF(435) ]; R = 1; G = 1; B = 1; [L M S] = [R G B] * M; λG=546 nm λB=435 nm
RGB color-matching function • What proportion of the R, G, and B primaries is required to match a spectral color? 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;
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?
RGB color-matching function [390 391 392 … 729 730] W = DomainSmjSRF(1); len = length(W); % compute M assuming equal-intensity primaries M = [ EvalSmjSRF(Rnm) * 1 EvalSmjSRF(Gnm) * 1 EvalSmjSRF(Bnm) * 1]; Minv = inv(M); % integrate the color-matching function CMFsum = [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 Bs Rs = 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 function CMF = zeros(len, 3); for n = 1 : len CMF(n,:) = EvalSmjSRF(W(n)) * Minv; end
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
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 …
CIE 1931 XYZ color-matching function Intended property:Y = luminosity Intended property:non-negative
A special metamer e2 Energy density e1 400 nm wd 700 nm These determine chromaticity Dominant wavelength = wd Excitation purity = (e2-e1) / (e2+e1) Luminance is related to the integration of the spectrum (as we saw before)
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
xz chromaticity You’ve never seen this plot, but it is perfectly valid. The standard plots the x and y chromaticity values.
CIE 1931 xy chromaticity (derived from SMJ data) Intended property:non-negative Intended property:fitted to edge of right triangle Intended property:white point at(1/3, 1/3, 1/3)
CIE 1931 xy chromaticity (actual CIE standard) Pure (saturated) spectral colors around the edge of the plot Less pure (desaturated) colors in the interior of the plot Are the colors correct ? White at the centroid of the plot (1/3, 1/3) Image from www.wikipedia.com
CIE 1931 rg chromaticity (derived from SMJ data) Intended property:white point at(1/3, 1/3, 1/3)
rb chromaticity (derived from SMJ data) Intended property:white point at(1/3, 1/3, 1/3)
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?
CIE 1931 RGB gamut All dominant wavelengths can be reproduced, but many cannot reach full saturation. G= 546 nm No finite set of primaries can reproduce the entire gamut. But more primaries do a better job. R= 700 nm So the colors on the xy chromaticity diagram cannot be correct, because no display can accurately reproduce them! B= 438 nm
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);
MATLAB and dichroic filter source Assumes projector light has flat spectrum (wrong) 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,:)); end 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); Image from www.edmundoptics.com Realistic primaries have wide spectrums. Why?
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?
Subtractive color Image from www.edmundoptics.com
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
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
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
Assignments • Next lecture: Some combination of lighting theory and z-buffer theory, TBD (Thursday 29 November) • Reading assignment: none (work on your projects)