Color Theory Kurt Akeley CS 248 Lecture 17

  • Slides: 36
Download presentation
Color Theory Kurt Akeley CS 248 Lecture 17 27 November 2007 http: //graphics. stanford.

Color Theory Kurt Akeley CS 248 Lecture 17 27 November 2007 http: //graphics. stanford. edu/courses/cs 248 -07/

Introduction Difficulties: n I’m learning this too n Terminology is used carelessly n There

Introduction Difficulties: n I’m learning this too n Terminology is used carelessly n There are lots of standards n CIE 1931, CIE 1964, Vos 1976, SMJ 1993, … Caveats: n Not comprehensive n Lots of CIE content, nothing on HSV or video n Units may be off (or missing all together) n Derived plots may differ slightly from standards CS 248 Lecture 17 Kurt Akeley, Fall 2007

Human photoreceptors Monochromatic scotopic vision (low light levels) Chromatic photopic vision (high light levels)

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. CS 248 Lecture 17 www. stat. auckland. ac. nz/~ihaka/787/lectures-vision. pdf Kurt Akeley, Fall 2007

Humans are trichromats M L Spectral sensitivities of human cones Stockman, Mac. Leod, and

Humans are trichromats M L Spectral sensitivities of human cones Stockman, Mac. Leod, and Johnson Journal of the Optical Society of America Volume 10, Number 12, December 1993 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 S CS 248 Lecture 17 [L M S] = Eval. Smj. SRF(lambda); [0. 0197 0. 0372 0. 0104] = Eval. Smj. SRF(470); All three contributions are non-zero (the plots overlap)! Kurt Akeley, Fall 2007

Luminosity function Sum of L, M, and S responses for photopic vision ? (Fv.

Luminosity function Sum of L, M, and S responses for photopic vision ? (Fv. D pp. 576) CS 248 Lecture 17 Kurt Akeley, Fall 2007

Comparison of luminosity functions Yes, the units are different. We are interested in the

Comparison of luminosity functions Yes, the units are different. We are interested in the shapes. Derived from SMJ spectralresponse data by simple addition CS 248 Lecture 17 From Wikipedia Kurt Akeley, Fall 2007

Luminous efficacy (and efficiency) How much of the radiated energy (efficacy/efficiency) or wall-socket energy

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. CS 248 Lecture 17 Source: Wikipedia Kurt Akeley, Fall 2007

Metamers Response is linear So response to an energy spectrum is the sum of

Metamers Response is linear So response to an energy spectrum is the sum of the responses to the individual spectral components n 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 … CS 248 Lecture 17 Kurt Akeley, Fall 2007

CIE 1931 RGB primaries [L M S] = Eval. Smj. SRF(700)*Sr + Eval. Smj.

CIE 1931 RGB primaries [L M S] = Eval. Smj. SRF(700)*Sr + Eval. Smj. SRF(546)*Sg + Eval. Smj. SRF(435)*Sb); λR=700 nm M = [ Eval. Smj. SRF(700) Eval. Smj. SRF(546) Eval. Smj. SRF(435) ]; R = 1; G = 1; B = 1; [L M S] = [R G B] * M; λG=546 nm λB=435 nm CS 248 Lecture 17 Kurt Akeley, Fall 2007

RGB color-matching function What proportion of the R, G, and B primaries is required

RGB color-matching function What proportion of the R, G, and B primaries is required to match a spectral color? M = [ Eval. Smj. SRF(700) Eval. Smj. SRF(546) Eval. Smj. SRF(435) ]; R = 1; G = 1; B = 1; [L M S] = [R G B] * M; [R G B] = [L M S] * Minv; CMF(lambda) = Eval. Smj. SRF(lambda) * Minv; CS 248 Lecture 17 Kurt Akeley, Fall 2007

RGB color-matching function Primary amplitudes are adjusted to give equal areas under all three

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? CS 248 Lecture 17 Kurt Akeley, Fall 2007

RGB color-matching function [390 391 392 … 729 730] W = Domain. Smj. SRF(1);

RGB color-matching function [390 391 392 … 729 730] W = Domain. Smj. SRF(1); len = length(W); % compute M assuming equal-intensity primaries M = [ Eval. Smj. SRF(Rnm) * 1 Eval. Smj. SRF(Gnm) * 1 Eval. Smj. SRF(Bnm) * 1]; Minv = inv(M); % integrate the color-matching function CMFsum = [0 0 0]; for n = 1 : len CMFsum = CMFsum + Eval. Smj. SRF(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 = [ Eval. Smj. SRF(Rnm) * Rs Eval. Smj. SRF(Gnm) * Gs Eval. Smj. SRF(Bnm) * Bs]; Minv = inv(M); % compute the color-matching function CMF = zeros(len, 3); for n = 1 : len CMF(n, : ) = Eval. Smj. SRF(W(n)) * Minv; end CS 248 Lecture 17 Kurt Akeley, Fall 2007

Negative primaries Can’t add a negative primary amount So a negative match adds the

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 CS 248 Lecture 17 Kurt Akeley, Fall 2007

CIE 1931 XYZ primaries Derived by linear transformation from the RGB primaries: The matrix

CIE 1931 XYZ primaries Derived by linear transformation from the RGB primaries: The matrix coefficients were (obviously) chosen carefully n We’ll see some of the desirable properties in later slides The XYZ primaries are imaginary CS 248 Lecture 17 Kurt Akeley, Fall 2007

CIE 1931 XYZ color-matching function Intended property: Y = luminosity Intended property: non-negative CS

CIE 1931 XYZ color-matching function Intended property: Y = luminosity Intended property: non-negative CS 248 Lecture 17 Kurt Akeley, Fall 2007

A special metamer e 2 Energy density e 1 400 nm wd Dominant wavelength

A special metamer e 2 Energy density e 1 400 nm wd Dominant wavelength = wd 700 nm These determine chromaticity Excitation purity = (e 2 -e 1) / (e 2+e 1) Luminance is related to the integration of the spectrum (as we saw before) CS 248 Lecture 17 Kurt Akeley, Fall 2007

XYZ chromaticity Rescale X, Y, and Z to remove luminance, leaving chromaticity: Because the

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 CS 248 Lecture 17 Kurt Akeley, Fall 2007

xz chromaticity You’ve never seen this plot, but it is perfectly valid. The standard

xz chromaticity You’ve never seen this plot, but it is perfectly valid. The standard plots the x and y chromaticity values. CS 248 Lecture 17 Kurt Akeley, Fall 2007

CIE 1931 xy chromaticity (derived from SMJ data) Intended property: non-negative Intended property: fitted

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) CS 248 Lecture 17 Kurt Akeley, Fall 2007

CIE 1931 xy chromaticity (actual CIE standard) Pure (saturated) spectral colors around the edge

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 CS 248 Lecture 17 Kurt Akeley, Fall 2007

CIE 1931 rg chromaticity (derived from SMJ data) Intended property: white point at (1/3,

CIE 1931 rg chromaticity (derived from SMJ data) Intended property: white point at (1/3, 1/3) CS 248 Lecture 17 Kurt Akeley, Fall 2007

rb chromaticity (derived from SMJ data) Intended property: white point at (1/3, 1/3) CS

rb chromaticity (derived from SMJ data) Intended property: white point at (1/3, 1/3) CS 248 Lecture 17 Kurt Akeley, Fall 2007

Gamut is the chromaticities that can be generated by a set of primaries Because

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? CS 248 Lecture 17 Kurt Akeley, Fall 2007

CIE 1931 RGB gamut G = 546 nm All dominant wavelengths can be reproduced,

CIE 1931 RGB gamut G = 546 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. R = 700 nm B = 438 nm CS 248 Lecture 17 So the colors on the xy chromaticity diagram cannot be correct, because no display can accurately reproduce them! Kurt Akeley, Fall 2007

MATLAB code RGBr RGBg RGBb XYZr XYZg XYZb xyzr xyzg xyzb = = =

MATLAB code RGBr RGBg RGBb XYZr XYZg XYZb xyzr xyzg xyzb = = = = = Eval. Smj. SRF(Rnm) Eval. Smj. SRF(Gnm) Eval. Smj. SRF(Bnm) RGBr * Cie. M; RGBg * Cie. M; RGBb * Cie. M; XYZr / (XYZr(1) XYZg / (XYZg(1) XYZb / (XYZb(1) * Minv; + XYZr(2) + XYZr(3)); + XYZg(2) + XYZg(3)); + XYZb(2) + XYZb(3)); … plot([xyzr(1) xyzg(1) xyzb(1) xyzr(1)], . . . [xyzr(2) xyzg(2) xyzb(2) xyzr(2)], . . . ‘c. -', 'linewidth', lw); CS 248 Lecture 17 Kurt Akeley, Fall 2007

Short-persistence phosphor CRT gamut CS 248 Lecture 17 Kurt Akeley, Fall 2007

Short-persistence phosphor CRT gamut CS 248 Lecture 17 Kurt Akeley, Fall 2007

Long-persistence phosphor CRT gamut CS 248 Lecture 17 Kurt Akeley, Fall 2007

Long-persistence phosphor CRT gamut CS 248 Lecture 17 Kurt Akeley, Fall 2007

LCD projector gamut (hypothetical) CS 248 Lecture 17 Kurt Akeley, Fall 2007

LCD projector gamut (hypothetical) CS 248 Lecture 17 Kurt Akeley, Fall 2007

MATLAB and dichroic filter source Assumes projector light has flat spectrum (wrong) RGBr =

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 = Eval. Dichroic. Rgb. TF(W(n)); RGBr = RGBr + (TF(1). * CMF(n, : )); RGBg = RGBg + (TF(2). * CMF(n, : )); RGBb = RGBb + (TF(3). * CMF(n, : )); end XYZr = RGBr * Cie. M; XYZg = RGBg * Cie. M; XYZb = RGBb * Cie. M; xyzr = XYZr / (XYZr(1) + XYZr(2) + XYZr(3)); xyzg = XYZg / (XYZg(1) + XYZg(2) + XYZg(3)); xyzb = XYZb / (XYZb(1) + XYZb(2) + XYZb(3)); Image from www. edmundoptics. com Realistic primaries have wide spectrums. Why? … plot([xyzr(1) xyzg(1) xyzb(1) xyzr(1)], . . . [xyzr(2) xyzg(2) xyzb(2) xyzr(2)], . . . ‘c. -', 'linewidth', lw); CS 248 Lecture 17 Kurt Akeley, Fall 2007

Subtractive color We have been adding primaries with spectra that are (almost) mutually exclusive

Subtractive color We have been adding primaries with spectra that are (almost) mutually exclusive This works for displays, but not for printing n It could work for printing, if dye were reflective and could be placed in very small, nonoverlapping, regions n 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: CS 248 Lecture 17 Kurt Akeley, Fall 2007

Subtractive color CS 248 Lecture 17 Image from www. edmundoptics. com Kurt Akeley, Fall

Subtractive color CS 248 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

Additive and subtractive primaries The statement that “the additive primaries are red, green, and blue” is clearly incorrect n Any set of three non-colinear primaries yields a gamut n Primaries that appear red, green, and blue are a good choice, but not the only choice n 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 CS 248 Lecture 17 do so are acceptable “primaries”Kurt Akeley, Fall 2007 that n

Final thoughts CIE RGB and CIE XYZ are color spaces Many other color spaces,

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 CS 248 lecture notes for many details: n http: //graphics. stanford. edu/courses/cs 248 -06/color 1. html CS 248 Lecture 17 Kurt Akeley, Fall 2007

Summary Perceived color is the ratio of (linear) L, M, and S stimulation n

Summary Perceived color is the ratio of (linear) L, M, and S stimulation n It is not possible to distinguish between “metamers” n Three degrees of freedom need for (at least) three primaries Everything derives from the human spectral-response function n Luminosity function (I think) n Reasonable choices for primaries n Color-matching functions (RGB and XYZ) n Chromaticity diagrams (rg and xy) Three primaries cannot reproduce the entire human gamut n Use chromaticity diagram to understand what can be reproduced Subtractive colors n Are a convenient fiction (like ‘holes’ in semiconductor theory) n The true color arithmetic is unchanged CS 248 Lecture 17 Kurt Akeley, Fall 2007

Assignments Next lecture: Some combination of lighting theory and z -buffer theory, TBD (Thursday

Assignments Next lecture: Some combination of lighting theory and z -buffer theory, TBD (Thursday 29 November) Reading assignment: none (work on your projects) CS 248 Lecture 17 Kurt Akeley, Fall 2007

End CS 248 Lecture 17 Kurt Akeley, Fall 2007

End CS 248 Lecture 17 Kurt Akeley, Fall 2007