INTRODUCTION
Dr. – CS576 Lecture 4 Page 1
CCOOLLOORR TTHHEEOORRYY
Dr. – CS576 Lecture 4 Page 2
TTOOPPIICCSS TTOO BBEE CCOOVVEERREEDD
The color problem
Cone response and Tristimulus Vectors
Solution to the Color problem – using CM Diagrams
Color Spaces and Examples
Displays
Color Quantization
Dr. – CS576 Lecture 4 Page 3
TTHHEE CCOOLLOORR PPRROOBBLLEEMM
How do we perceive an object?
How do we capture the image of an object?
• Digital Still Camera
• Camcorders
• Film processing/scanning
How do render an object image
• Storage/Transfer issues
• Rendering on Client
• Printing
The Color Problem – How do you ensure that the colors
in the image of a rendered object look the same as the
original colors of that object?
Dr. – CS576 Lecture 4 Page 4
EEYYEE SSTTRRUUCCTTUURREE
Dr. – CS576 Lecture 4 Page 5
RREETTIINNAA
Dr. – CS576 Lecture 4 Page 6
RREETTIINNAA
Dr. – CS576 Lecture 4 Page 7
HHOOWW DDOO WWEE PPEERRCCEEIIVVEE CCOOLLOORRSS??
Spectrum of visible light f( ): =360-830 nm
( = wavelength)
In the retina: 3 types of cones with different spectral
absorptance (or sensitivity). The response c i of a cone
of type i is modeled as
dfsc ii )()(
max
min
=
Dr. – CS576 Lecture 4 Page 8
SSPPEECCTTRRAALL DDIISSTTRRIIBBUUTTIIOONN
Dr. – CS576 Lecture 4 Page 9
SSPPEECCTTRRAALL SSEENNSSIITTIIVVIITTYY
Sensitivity for Entire Spectrum
Dr. – CS576 Lecture 4 Page 10
SSPPEECCTTRRAALL SSEENNSSIITTIIVVIITTYY OOFF CCOONNEESS
Dr. – CS576 Lecture 4 Page 11
DDIISSCCRREETTEE FFUUNNCCTTIIOONN EEVVAALLUUAATTIIOONN OOFF CCOONNEE
RREESSPPOONNSSEE
Instead of evaluating the cone response as a continuous
integral function, we will use discrete quantities with
summations
• Represent the light spectral stimulus f() as a
vector f on N different wavelength (with a
spectral interval of 10 nm)
• Represent each sensitivity si() as vector si as N
different wavelength
Then the cone response is represented by a vector
(called tristimulus vector):
C = STf
Dr. – CS576 Lecture 4 Page 12
TTRRIISSTTIIMMUULLUUSS VVEECCTTOORRSS
C = STf is a 3-vector (called color) which represents how
we perceive a light with spectrum f (which is a N-vector).
If two different spectra f1 and f2 produce the same color
C = STf1 = S
Tf2 , then they look the same, that is, they are
undistinguishable by the human eye.
Thus, it is not important that after processing,
transmission and reproduction we recreate the same
light spectrum f as the original, but that we reproduce a
light spectrum that has the same perceived color c.
Thus, 3 values (the entries of C) are sufficient to
represent the color of a pixel (instead of N values)
Dr. – CS576 Lecture 4 Page 13
IISSSSUUEESS WWIITTHH GGEENNEERRAATTIINNGG CCOOLLOORR
The tristimulus or color equation is C = STf
• We need to know S
• We need to know f
We don’t actually know S; we will show soon that it
doesn’t matter
To understand f we need to know
• How should we capture a light spectrum?
(How do we take a color picture?)
• How do we reproduce a light spectrum?
(How do we render a color?)
Dr. – CS576 Lecture 4 Page 14
HHOOWW DDOOEESS AA 33–CCCCDD CCAAMMEERRAA WWOORRKK??
Light is refracted onto 3 CCDs (through a prism). In front
of each CCD there is a color filter with frequency
response mi(). Thus, a pixel of the i-th CCD gives an
output
dfma ii )()(
max
min
=
In discrete form: a = MTf where the i-th column of M
contains the samples of mi()
Note that M can only have positive entries!
Dr. – CS576 Lecture 4 Page 15
HHOOWW DDOOEESS AA CCOOLLOORR PPRROOJJEECCTTOORR WWOORRKK??
Color Projectors work using Additive Synthesis: there
are actually 3 light projectors focusing light onto the
same spot.
Let the light spectra produced by each be: p1, p2, p3 . The
intensity of each projector can be controlled at each
pixel via a gain ai . Thus, the actual light spectrum on the
screen is g = p1a1 + p2a2 + p3a3 = Pa
where P=[ p1, p2, p3 ] (size: Nx3) and
a=[ a1, a2, a3]
T (size:3×1)
Are 3 projectors able to create all the light spectra that
we want to reproduce? No! But we just need that they
create the colors we need to reproduce.
Dr. – CS576 Lecture 4 Page 16
CCOOLLOORR PPRROOJJEECCTTOORR ((22))
Let { p1, p2, p3 } by three “colorimetrically independent”
light sources (called primaries).
Then, given any spectrum f, we can always find gains a
such that the light g = Pa generated by additive
synthesis has the same color of f.
Proof: We need to find a vector a such that
STg = STPa = C. Just choose a=(STP)-1C.
Problem: a may have negative components, which
makes no physical sense (gains and spectra can only
have positive values!)
Dr. – CS576 Lecture 4 Page 17
TTHHEE PPRROOBBLLEEMM
Given a set of primaries P, how can we be sure that for
any light spectrum f, the projector reproduces a light
spectrum with the same color of f?
Dr. – CS576 Lecture 4 Page 18
TTHHEE PPRROOBBLLEEMM ((22))
Given a set of primaries P, design the “filters” M of a
color camera such that for any input spectrum f, the
light g generated by the projector has the same color of
f.
In other words: we want that the projectors, using as
gains the output a of the camera, create a light g = Pa
such that STg = STPa = STf = C.
And we want to do it without knowing S (which is
difficult to compute)
Dr. – CS576 Lecture 4 Page 19
PPRROOBBLLEEMM SSOOLLUUTTIIOONN
The solution is based on color matching experiments
The columns { m1, m2, m3 } of M (size: Nx3) are called the
color matching functions (CMF) associated with the
primaries P.
Problem (again): CMF can take on negative values.
Dr. – CS576 Lecture 4 Page 20
WWHHAATT AARREE CCOOLLOORR MMAATTCCHHIINNGG FFUUNNCCTTIIOONNSS??
Like we said before: the three CMFs { m1, m2, m3 }
correspond to the “ filters” in a color camera to generate
the three color channels a = { a1, a2, a3 }.
Each color signal can be used to control the intensities
of the primaries (projectors) in order to generate a
spectrum g = Pa that has the same color as f
STg = STPa
Note: Given a set or primaries P, there is just one set of
CMFs M associated to it, and vice-versa
Remember, C is the “perceptual” color vector; a is the
color vector associated to the chosen primaries
Dr. – CS576 Lecture 4 Page 21
CCHHAANNGGIINNGG PPRRIIMMAARRIIEESS
What happens when we change primaries? (e.g., we use
a different projector, or we use a CRT screen instead of
a projector)
Suppose we use primaries Q instead of P. We want to
find a new color vector b such that
STPa = STQb
The solution is b=Ta with T=(STQ)-1(STP)
(T is a 3×3 matrix which is independent of a)
Thus T is a linear operator that maps from one color
space into a new one.
Dr. – CS576 Lecture 4 Page 22
CCIIEE CCMMFFSS
The International Commission on Illumination (CIE) has
standardized two sets of CMFs: RGB and XYZ
RGB: The CMF’s are associated with monochromatic
primaries at wavelengths of 700, 546 and 435 nm.
(Note that one RGB CMF takes on -ve values.)
XYZ: One of the 3 CMFs, y(), is the luminous efficient
function, which gives the relative sensitivity of the eye
to each wavelength. Y is called luminance. (Note that all
XYZ CMFs are positive; however, it can be shown that
the corresponding primaries are not physically
realizable)
Note: {r( ),g( ),b( )} ({x( ),y( ),z( )}) are the CMFs
(corresponding to the columns of M); the values {R,G,B}
{X,Y,Z} are the color channels (corresponding to a)
Dr. – CS576 Lecture 4 Page 23
CCIIEE CCMMFFSS
Dr. – CS576 Lecture 4 Page 24
CCIIEE CCMMFFSS
Dr. – CS576 Lecture 4 Page 25
RRGGBB && XXYYZZ CCOOLLOORR SSPPAACCEE
Dr. – CS576 Lecture 4 Page 26
CCHHRROOMMAATTIICCIITTYY DDIIAAGGRRAAMMSS
Can we represent all colors by additive synthesis of 3
primaries? No! That’s because CMFs can assume
negative values, and the frequency responses of the
color filters can only be positive.
Problem: represent all achievable colors on a 2-D plane
(color channels a1a2a3 live in a 3-D space!)
Solution: normalize colors to live in 2-D.
Example: CIE xy chromaticity diagram. Given a color
value (X,Y,Z), compute the normalized values
x=X/(X+Y+Z), y=Y/(X+Y+Z), z=Z/(X+Y+Z).
Then, plot only the colors corresponding to 2
chromaticity coordinates (x, y)
Dr. – CS576 Lecture 4 Page 27
NNOORRMMAALLIIZZEEDD XXYYZZ SSPPAACCEE
Dr. – CS576 Lecture 4 Page 28
CCIIEE XXYY CCHHRROOMMAATTIICCIITTYY DDIIAAGGRRAAMMSS
Dr. – CS576 Lecture 4 Page 29
CCOOLLOORR GGAAMMUUTTSS
Color gamut of a color synthesis device = set of
obtainable colors. Represented by a polygonal on the
chromaticity diagram, example shown here
Dr. – CS576 Lecture 4 Page 30
VVIISSUUAALLIIZZAATTIIOONNSS
Color Applets
Visualization of CIE XYZ and RGB
Visualization of Color Gamuts
https://graphics.stanford.edu/courses/cs178-10/applets/
Dr. – CS576 Lecture 4 Page 31
LLIINNEEAARR TTRRAANNSSFFOORRMMAATTIIOONNSS OOFF RRGGBB CCOOLLOORR
SSPPAACCEESS
RGB: used in CRT monitors (additive synthesis)
YIQ (used in NTSC TV). T=
3120. 0.523 -0.211
0.3220.274 -0.596
0.114 0.587 0.299
YUV (used in PAL, SECAM). T=
0.1- 0.515- 0.615
0.436 0.289- 0.147-
0.114 0.587 0.299
YCrCb (for JPEG, MPEG). T=
5 0. 0.3313 -0.1687-
0.0813 -0.41870.500 –
0.114 0.587 0.299
2/7/2001
Dr. – CS576 Lecture 4 Page 32
WWHHYY IISS RRGGBB NNOOTT UUSSEEDD??
Similarly to the processing in the human visual system,
transformed color spaces such as YIQ, YUV, YCrCb
represent color with luminance (Y) and chrominance
(the other 2 channels). Advantages:
• We can subsample the chrominance channels
(e.g., 4:2:2, 4:2:0 subsampling schemes)
• We can quantize the chrominance channels more
coarsely (with fewer bits)
• The chrominance channels are rather
uncorrelated with the luminance channel, which
yields better compression.
Dr. – CS576 Lecture 4 Page 33
OOTTHHEERR TTRRAANNSSFFOORRMMAATTIIOONNSS
CMY: Cyan, magenta, yellow – complementary to red,
green and blue respectively. Used for subtractive
synthesis from white in color printers.
(C, M, Y) = (1,1,1) – (R,G,B)
CMYK: like CMY, uses black (K) as fourth color.
Given (C, M, Y):
K=min(C, M, Y); C=C-K; M=M-K; Y=Y-K
Dr. – CS576 Lecture 4 Page 34
UUNNIIFFOORRMM CCOOLLOORR SSPPAACCEESS
CIE XYZ is not perceptually uniform because perceptual
differences between colors do not correspond to equal
distance in color space
CIE defined two uniform color spaces:
CIE Luv and CIE Lab:
• L depends only on Y (luminance)
• Radial distance (e.g. sqrt(u2+ v2 )) correlates to
chroma (or saturation)
• Angular position (e.g. tan-1(u/v)) correlates to hue
Dr. – CS576 Lecture 4 Page 35
HHSSVV CCOOLLOORR SSPPAACCEE
HSV is based on a cylindrical coordinate system
H (hue) is measured in angles with respect to the V
(value) axis. S (saturation) goes from 0 to 1.
Complementary colors in HSV are 180 degrees from
each other.
Hue distinguishes among colors such as red, green,
purple, and yellow. Saturation refers to how far color is
from a gray of equal intensity. Value represents the
lightness (or brightness)
Dr. – CS576 Lecture 4 Page 36
CCOOLLOORR SSPPAACCEE EEXXAAMMPPLLEESS –– RRGGBB
Dr. – CS576 Lecture 4 Page 37
CCOOLLOORR SSPPAACCEE EEXXAAMMPPLLEESS –– YYIIQQ
Dr. – CS576 Lecture 4 Page 38
CCOOLLOORR SSPPAACCEE EEXXAAMMPPLLEESS –– YYUUVV
Dr. – CS576 Lecture 4 Page 39
CCOOLLOORR DDIISSPPLLAAYYSS
Visible light is produce by bombardment of a thin layer
of phosphor by a beam of electrons.
Shadow-mask color CRT: mosaic of r,g,b light emitting
phosphors illuminated by 3 independent electron
beams.
Color is controlled through application of different
voltage to r, g, b guns.
How can we take into account non-linearities?
Dr. – CS576 Lecture 4 Page 40
GGAAMMMMAA CCOORRRREECCTTIIOONN
For each gun, the power of the emitted light Si() is a
function of the control voltage v i . Ideally, the
relationship would be linear: Si() = vi p i() (so we would
set vi = ai.) In practice, the relation is not linear. A better
approximation is
Si() =( vi / v)
p i()
where v is the maximum value of the voltage and is the
exponential parameter. The monitor is usually
approximately equal to 2.2
Thus, given a value of ai, instead of controlling the light
with voltage vi = ai, we should use vi = v ai
1/
This transformation is called gamma correction.
Dr. – CS576 Lecture 4 Page 41
CCCCDD CCAAMMEERRAASS
3 CCD
• Light is refracted into each CCD using a prism
• In front of each CCD there is a color filter
(corresponding to CMF functions r ,g ,b)
• More expensive (need 3 CCDs per pixel) – but
better resolution
1 CCD
• There is 1 filter (r, g or b) on top of each pixel.
The filters are chosen according to a “mosaic”
layout. E.g.
r g b r g b r g b
g b r g b r g b r
b r g b r g b r g
• Cheaper (1 CCD) but with less color resolution
(e.g.: for an r pixel, the other colors must be
interpolated from nearby pixels.
Dr. – CS576 Lecture 4 Page 42
CCOOLLOORR QQUUAANNTTIIZZAATTIIOONN
What is color quantization and why is it required?
Frame buffer architecture: Image is stored in a video
memory from which controllers constantly refresh the
display screen. How many bits per pixel should we use?
(8-12-16-24…)
The more pixels you use, the longer it takes to read and
longer to refresh your monitor screen.
Palletized image: Uses a finite set of colors indexed in a
table (palette or color map or LUT). You may choose this
color mapping in two ways
• Pre designed or fixed
• Adaptively – “quantized” version is similar to the
original
Dr. – CS576 Lecture 4 Page 43
AADDAAPPTTIIVVEE CCOOLLOORR QQUUAANNTTIIZZAATTIIOONN MMEETTHHOODDSS
The process occurs in stages
• Sampling the original image for color statistics –
(Histogram)
• Choosing a color map based on those statistics
• Mapping colors to their representative colors to
get new image
Different algorithms proposed and used depend on how
the second step above is done
• Uniform Quantization
• Median Cut – (Heckbert)
• Octree – (Gervautz & Purgathofer)
• Peano Curve Mapping
Dr. – CS576 Lecture 4 Page 44
QQUUEESSTTIIOONNSS
The chromaticity diagram in (x, y) represents the
normalized color matching functions X, Y and Z.
Prove that
Z = [ (1-x-y)/y ] Y
Dr. – CS576 Lecture 4 Page 45
QQUUEESSTTIIOONNSS
The chromaticity space is a 2D space obtained by
projecting the 3D conical XYZ space onto a plane.
• What is the equation of this plane
• Why is there no black color in the chromaticity
space?
• Where do the CIE primaries lie in the
chromaticity space?