VIEWS: 38 PAGES: 36 POSTED ON: 5/20/2010
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 … CS248 Lecture 17 Kurt Akeley, Fall 2007 Human photoreceptors Monochromatic Chromatic scotopic vision photopic vision (low light levels) (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 CS248 Lecture 17 Kurt Akeley, Fall 2007 Humans are trichromats Spectral sensitivities of human cones Stockman, MacLeod, and Johnson M Journal of the Optical Society of America Volume 10, Number 12, December 1993 L Table 8 Determined by chemistry and retinal coverage Monochromat: Horshoe crabs Dichromat: dogs Trichromat: people, most cameras Tetrachromat: fancy cameras Pentachromat: Mallard ducks Monochromatic stimulus [L M S] = EvalSmjSRF(lambda); [0.0197 0.0372 0.0104] = EvalSmjSRF(470); All three contributions are S 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 Yes, the units are different. We are interested in the shapes. Derived from SMJ From Wikipedia spectral-response data by simple addition 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. CS248 Lecture 17 Source: Wikipedia 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 [L M S] = EvalSmjSRF(700)*Sr + λR=700 nm 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; λG=546 nm λB=435 nm CS248 Lecture 17 Kurt Akeley, Fall 2007 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; 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 [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 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: é0.49 0.17697 0.00ù 1 ê ú [X Y Z ]= ×R G [ B ]×ê0.31 0.81240 0.01ú 0.17697 ê ú ê0.20 0.01063 0.99ú ë û 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 … 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 e2 Energy density e1 400 nm wd 700 nm These determine Dominant wavelength = wd chromaticity Excitation purity = (e2-e1) / (e2+e1) Luminance is related to the integration of the spectrum (as we saw before) CS248 Lecture 17 Kurt Akeley, Fall 2007 XYZ chromaticity Rescale X, Y, and Z to remove luminance, leaving chromaticity: X Y Z x= y= z= X+Y+ Z X+Y+ Z X+Y+ Z 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 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: fitted to edge of right triangle Intended property: white point at (1/3, 1/3, 1/3) CS248 Lecture 17 Kurt Akeley, Fall 2007 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 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 All dominant wavelengths can be reproduced, but many cannot reach full G = 546 nm saturation. 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 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 Assumes projector RGBr = [0 0 0]; light has flat RGBg = [0 0 0]; spectrum (wrong) 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; Image from www.edmundoptics.com XYZg = RGBg * CieM; XYZb = RGBb * CieM; xyzr = XYZr / (XYZr(1) + XYZr(2) + XYZr(3)); Realistic primaries have xyzg = XYZg / (XYZg(1) + XYZg(2) + XYZg(3)); xyzb = XYZb / (XYZb(1) + XYZb(2) + XYZb(3)); wide spectrums. Why? … 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 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 CS248 Lecture 17 Image from www.edmundoptics.com 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 CS248 Lecture 17 Kurt Akeley, Fall 2007