程序代写代做代考 algorithm C AI COLOR THEORY

COLOR THEORY
COLOR THEORY
Dr. Parag Havaldar – CS576 Lecture 4 Page 1

TOPICS TO BE COVERED
TOPICS TO BE COVERED
The color problem
Cone response and Tristimulus Vectors Solution to the Color problem – using CMFs Chromaticity Diagrams
Color Spaces and Examples
Displays
Color Quantization
Dr. Parag Havaldar – CS576 Lecture 4 Page 2

THE COLOR PROBLEM
THE COLOR PROBLEM
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. Parag Havaldar – CS576 Lecture 4 Page 3

EYE STRUCTURE
EYE STRUCTURE
Dr. Parag Havaldar – CS576 Lecture 4 Page 4

RETINA
RETINA
Dr. Parag Havaldar – CS576 Lecture 4 Page 5

RETINA
RETINA
Dr. Parag Havaldar – CS576 Lecture 4 Page 6

HOW DO WE PERCEIVE COLORS?
HOW DO WE PERCEIVE COLORS?
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
ci = max si() f ()d min
Dr. Parag Havaldar – CS576 Lecture 4 Page 7

SPECTRAL DISTRIBUTION
SPECTRAL DISTRIBUTION
Dr. Parag Havaldar – CS576 Lecture 4 Page 8

SPECTRAL SENSITIVITY
SPECTRAL SENSITIVITY
Sensitivity for Entire Spectrum
Dr. Parag Havaldar – CS576 Lecture 4 Page 9

SPECTRAL SENSITIVITY OF CONES
SPECTRAL SENSITIVITY OF CONES
Dr. Parag Havaldar – CS576 Lecture 4 Page 10

DISCRETE FUNCTION EVALUATION OF CONE
DISCRETE FUNCTION EVALUATION OF CONE RESPONSE
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. Parag Havaldar – CS576 Lecture 4 Page 11

TRISTIMULUS VECTORS
TRISTIMULUS VECTORS
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 = STf2 , 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. Parag Havaldar – CS576 Lecture 4 Page 12

ISSUES WITH GENERATING COLOR
ISSUES WITH GENERATING COLOR
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. Parag Havaldar – CS576 Lecture 4 Page 13

HOW DOES A 3-CCD CAMERA WORK?
HOW DOES A 3-CCD CAMERA WORK?
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
ai = max mi() f ()d 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. Parag Havaldar – CS576 Lecture 4 Page 14

HOW DOES A COLOR PROJECTOR WORK?
HOW DOES A COLOR PROJECTOR WORK?
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. Parag Havaldar – CS576 Lecture 4 Page 15

COLOR PROJECTOR (2)
COLOR PROJECTOR (2)
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. Parag Havaldar – CS576 Lecture 4 Page 16

THE PROBLEM
THE PROBLEM
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. Parag Havaldar – CS576 Lecture 4 Page 17

THE PROBLEM (2)
THE PROBLEM (2)
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. Parag Havaldar – CS576 Lecture 4 Page 18

PROBLEM SOLUTION
PROBLEM SOLUTION
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. Parag Havaldar – CS576 Lecture 4 Page 19

WHAT ARE COLOR MATCHING FUNCTIONS?
WHAT ARE COLOR MATCHING FUNCTIONS?
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. Parag Havaldar – CS576 Lecture 4 Page 20

CHANGING PRIMARIES
CHANGING PRIMARIES
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. Parag Havaldar – CS576 Lecture 4 Page 21

CIE CMFS
CIE CMFS
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. Parag Havaldar – CS576 Lecture 4 Page 22

CIE CMFS
CIE CMFS
Dr. Parag Havaldar – CS576 Lecture 4 Page 23

CIE CMFS
CIE CMFS
Dr. Parag Havaldar – CS576 Lecture 4 Page 24

RGB & XYZ COLOR SPACE
RGB & XYZ COLOR SPACE
Dr. Parag Havaldar – CS576 Lecture 4 Page 25

CHROMATICITY DIAGRAMS
CHROMATICITY DIAGRAMS
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. Parag Havaldar – CS576 Lecture 4 Page 26

NORMALIZED XYZ SPACE
NORMALIZED XYZ SPACE
Dr. Parag Havaldar – CS576 Lecture 4 Page 27

CIE XY CHROMATICITY DIAGRAMS CIE XY CHROMATICITY DIAGRAMS
Dr. Parag Havaldar – CS576 Lecture 4 Page 28

COLOR GAMUTS
COLOR GAMUTS
Color gamut of a color synthesis device = set of obtainable colors. Represented by a polygonal on the chromaticity diagram, example shown here
Dr. Parag Havaldar – CS576 Lecture 4 Page 29

VISUALIZATIONS
VISUALIZATIONS
Color Applets
Visualization of CIE XYZ and RGB Visualization of Color Gamuts
Dr. Parag Havaldar – CS576 Lecture 4 Page 30

LINEAR TRANSFORMATIONS OF RGB COLOR LINEAR TRANSFORMATIONS OF RGB COLOR
2/7/2001
SPACES
RGB: used in CRT monitors (additive synthesis)
YIQ (used in NTSC TV). T= 0.211 – 0.523 0.312 
YUV (used in PAL, SECAM). T=  0.615 – 0.515 – 0.1  
0.299 0.587 0.114 0.596 – 0.274 0.322 
YCrCb (for JPEG, MPEG). T=  – 0.1687 – 0.3313 0. 5  
 0.299 0.587 0.114  – 0.147 – 0.289 0.436 
 0.299 0.587 0.114   0.500 – 0.4187 – 0.0813
Dr. Parag Havaldar – CS576 Lecture 4 Page 31

WHY IS RGB NOT USED? WHY IS RGB NOT USED?
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. Parag Havaldar – CS576 Lecture 4 Page 32

OTHER TRANSFORMATIONS
OTHER TRANSFORMATIONS
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. Parag Havaldar – CS576 Lecture 4 Page 33

UNIFORM COLOR SPACES
UNIFORM COLOR SPACES
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. Parag Havaldar – CS576 Lecture 4 Page 34

HSV COLOR SPACE
HSV COLOR SPACE
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. Parag Havaldar – CS576 Lecture 4 Page 35

COLOR SPACE EXAMPLES – RGB
COLOR SPACE EXAMPLES – RGB
Dr. Parag Havaldar – CS576 Lecture 4 Page 36

COLOR SPACE EXAMPLES – YIQ
COLOR SPACE EXAMPLES – YIQ
Dr. Parag Havaldar – CS576 Lecture 4 Page 37

COLOR SPACE EXAMPLES – YUV
COLOR SPACE EXAMPLES – YUV
Dr. Parag Havaldar – CS576 Lecture 4 Page 38

COLOR DISPLAYS
COLOR DISPLAYS
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. Parag Havaldar – CS576 Lecture 4 Page 39

GAMMA CORRECTION
GAMMA CORRECTION
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 ai1/
This transformation is called gamma correction.
Dr. Parag Havaldar – CS576 Lecture 4 Page 40

CCD CAMERAS
CCD CAMERAS
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.
rgbrgbrgb gbrgbrgbr brgbrgbrg
• Cheaper (1 CCD) but with less color resolution (e.g.: for an r pixel, the other colors must be interpolated from nearby pixels.
Dr. Parag Havaldar – CS576 Lecture 4 Page 41

COLOR QUANTIZATION
COLOR QUANTIZATION
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. Parag Havaldar – CS576 Lecture 4 Page 42

ADAPTIVE COLOR QUANTIZATION METHODS
ADAPTIVE COLOR QUANTIZATION METHODS
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. Parag Havaldar – CS576 Lecture 4 Page 43

QUESTIONS
QUESTIONS
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. Parag Havaldar – CS576 Lecture 4 Page 44

QUESTIONS
QUESTIONS
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?
Dr. Parag Havaldar – CS576 Lecture 4 Page 45