Upload
lillian-sparks
View
225
Download
0
Tags:
Embed Size (px)
Citation preview
1
Color
To understand color, we must understand light
2
Light
An electromagnetic phenomenon, like television waves, infrared radiation, and x-rays
Color involves those waves that lie in a narrow band of wavelengths in the “visible spectrum”
380nm 450nm 490nm 560nm 590nm 630nm 780nm
3
Light Photons
• all light is comprised of photons• properties: velocity, wavelength, frequency, polarization
wavelength = velocity / frequency
• interact with matter : transmitted, reflected, absorbed
Spectral Distribution• # of photons at each frequency/wavelength• visible spectrum
4
How would you convert?
How do you convert from rgb to wavelength?
How do you convert from wavelength to RGB?
380nm 450nm 490nm 560nm 590nm 630nm 780nm
5
What Is color? -perception
A source of light, an object, andthe eye - brain interaction…
6
How do we see color?
Experiments were done to observe and measure what people see.
OBSERVER
RG
B T
RI-
STIM
ULU
STES
T L
AM
P
7
Radiometry - How does light propagate in the real world?
700nm 400nm
pure light
spectral distribution
white light
8
Life and Death of a Photon
Emission
Reflection
Absorption
9
Pure Spectral light
The eye responds to light with wavelengths between approximately 400 and 700 nm
Some spectral densities for pure spectral light, and how we perceive them:
400 500 600 700
wavelength
SpectralDensity(powerper unitwavelength)
Vio
let
Blu
e Gre
en
Yel
low O
ran
ge
Red
10
Lighting is a Global Problem
That is, if you consider any point in the environment, it receives light from all around
11
Surfaces are Rarely Mirrors
Specular surface
Diffuse Surface
12
Some Simplifying Assumptions
Wavelength independence• No fluorescence
Time invariance• No phosphorescence
Light transport in a vacuum• No participating media
Objects are isotropic• Reflectance characteristics are constant
over the surface
13
color Response
Cones A = “Red” B = “Green” C = “Blue”
14
RGB Color Model
WHITE
MAGENTA (1,0,1)RED (1,0,0)
BLACK
GREEN (0,1,0) CYAN (0,1,1)
BLUE (0,0,1)
YELLOW (1,1,0)
15
The RGB Model
An Additive color model based on the primitives Red Green and Blue
Most Commonly used in Computer Graphics
Approximates human visual response fairly well
16
RGB Color Space
This is a vector space with the RGB basis vectors defined by the properties of the monitor phosphors.
17
Device Dependency Unfortunately the choice of red,
green and blue and be quite different in different implementations.
If the phosphors colors are slightly different the vector space is different so we cannot use RGB to universally define a unique color.
We require a device independent color space.
RGB Space 1
RGB Space 2
18
Color & Vision
CIE 1931 Model
The CIE 1931 model is the most commonly used It defines three primary “colors” X, Y and Z that can
be used to describe all visible colors, as well as a standard white, called C.
The range of colors that can be described by combinations of other colors is called a color gamut.
Since it is impossible to find three colors with a gamut containing all visible colors, the CIE’s three primary colors are imaginary. They cannot be seen, but they can be used to define other visible colors.
19
Color & Vision 2
CIE 1931 Model
To define a color in CIE model, provide weights for the X, Y and Z primaries, just as you would for an RGB display (e.g. C = xX + yY + zZ)
X, Y and Z form a three dimensional color volume We can ignore the dimension of luminance by
normalizing with total light intensity, X+Y+Z = 1. This gives chromaticity values:
x = X/X+Y+Zy = Y/X+Y+Zz = 1 - x - y
20
Color & Vision
CIE 1931 Model
Plotting x and y gives the CIE chromaticity diagram
• Color gamuts are found by taking the convex hull of the primary colors
• Complements are found by inscribing a line from the color through C to the edge of the diagram
y
x0
00.7
0.8
C
green
redblue
yellowcyan
purple700
600
520
400
500
21
22
Color & Vision
CIE 1931 Model
23
Y primary describes the luminance component
Amount of primaries to match a color is (x, y, z), given by
For a CRT k is 680 lumens per watt.
CIE Standard Specification
y
x k C x d y k C y d z k C z d ( ) ( ) ( ) ( ) ( ) ( )
C( )
24
A cone shaped volume that contains all the visible colors could be built in the XYZ space
If (x, y, z) are the weights to match a color C, then C = xX + yY + zZ
(x + y + z) (x + y + z) as
CIE Chromaticity Diagram
xcx
x y zyc
y
x y zzc
z
x y z
( ),
( ),
( )
X
Y
Z
25
CIE Chromaticity Diagram
If we specify xc and yc, then zc can be calculated as (1 - xc - yc). In addition if y (luminance) is specified than x and z could be calculated. So given (xc, yc, y) the transformation corresponding to (x, y, z) is given as
xxcyc
y y y zxc ycyc
y
, ,1
26
C
27
Uses of CIE Chromaticity Diagram
When three primary colors are used, then all the colors in the triangle formed by the three primaries could be produced
This helps in comparing color gamuts,
i.e. collection of colors
yc
xc
28
Color Models
Color model is a geometric representation of the space of all colors such that any color is a point in that space
Traditionally color models for computer graphics were designed for specific devices
They could be classified based on• Hardware color generation i.e. RGB for displays,
CMY for printers, YIQ for television transmission• Color perception i.e. HSV for interactive color
specification.
29
RGB Color Model
Standard Model for color monitor
Primaries are Red, Green and Blue
Represents only a subset of perceivable colors
Known as Additive Model, because individual contributions of each primary are added
color Applet (http://mc2.cchem.berkeley.edu/Java/RGB/example1.html)
30
CMY Color Model
Standard for ink-jet and xerographic printers
Primaries are Cyan, Magenta and Yellow
Known as Subtractive Model,
Printer color gamut is smaller than CRT color gamut
C = 1-R, M = 1-G and Y = 1-B
31
YIQ Color Model Used in commercial TV broadcasting Primaries are Y (luminance) and I, Q which are the chrominance components Y is same as the y primary of CIE standard Designed for transmission efficiency and compatibility
with black and white television Exploits two properties of human visual system
• high sensitivity to change in luminance than to color variations• Objects small in the field of view produce limited color
sensation
B
G
R
Q
I
Y
311.0528.0212.0
321.0275.0596.0
114.0587.0299.0
32
HSV Color Model
Useful in user interface design for color specification
Primaries are Hue, Saturation and Value (luminance)
Considered as direct geometric representation of perception of color
Based on cylindrical coordinate system
H
S
V
Cyan
1200
Green Yellow
Red 00
MagentaBlue2400
Black0.0
1.0
33
RGB Color Space
MagentaCyan
Yellow
GreenRed
Blue
BlackWhite
34
CIE Standard
Standard developed by Commission Internationale de L'Eclairage (1931): a way of defining any color based on the r + g + b = 1 plane.
Based on three primaries which are able to produce ALL visible colours.
CIE chromaticity diagram is the view you would get looking at the plane x + y + z = 1, straight down the blue axis
Provides a standard reference for comparing other color systems
35
CIE Chromticity Diagram
Less natural than RGB
However standard is useful for converting between color spaces of different devices
36
CMY color
Subtractive scheme based on primitives: Cyan, Magenta and Yellow
Commonly used in color print production
37
Subtractive Colors
Subtractive color mixing results from selective absorption of light wavelengths
Layers of CMY ink Layers of CMY ink subtract inverse subtract inverse percentages from percentages from the reflected light the reflected light so that we see a so that we see a particular color.particular color.
38
CMYK
'black' generated by mixing the subtractive primaries is not as dense as that of a genuine black ink (one that absorbs throughout the visible spectrum),
four-color printing uses black ink in addition to the subtractive primaries
C=cyan, M=magenta, Y=yellow, K=key (black)
39
Color Space Conversions
Y
M
C
B
G
R
1
1
1
B
G
R
Y
M
C
1
1
1
kkY
kkM
kkC
Y
M
C
)1(
)1(
)1(
RGB to CMY and CMY to RGB:RGB to CMY and CMY to RGB:
CMYK to CMY:CMYK to CMY:
40
color Matching
How much R,G,B do you need to make a particular “pure” color?
41
The EyeThe Biological Camera
Lens, cornea and fluids focus light.
Six eye muscles orient the eye
Iris adjusts light Retina captures
images
42
Physiology of Eye Response
6 million cones in the fovea• cones sense red green or blue light• color perception region is very small
120 million rods over the whole eye• peripheral vision• motion sensitive
43
Photometry - How do we see light?
44
Evolution’s camera
45
Spatial distribution (cross-section)
46
Rods versus cones Rods are more tolerant in terms of handling
low light conditions• You don’t see color when it’s night
Cones give you better spatial acuity
47
Cones come in three flavorsBlue Green
Red
48
Visual Cortex: Tristimulus Reality?
Types of Cones:• Low: 560 nm red ?• Medium: 530 nm green ?• High: 420 nm blue ?
Signal to brain:• L - M red - green• H - (L+M) blue - yellow• L + M red + green overall
luminance Red/Green color blindness means no signal
L – M signal.
49
How many colors can we see?
Humans can discriminate about• 200 hues• 20 saturation values• 500 brightness steps
The NBS (National Broadcasting Society) lists 267 color names
What about across languages?• Seem to be about 11 basic ones
– white, black, red, green, yellow, blue, brown, purple, pink, orange, gray
50
Cones
Types• “red”, “green”, “blue”
51
Hue
Hue, Saturation, Lightness/Value
Color Cone
52
RGB Color Cube
53
The negative values for thered matching function around 500nm indicate that these colors cannot be produced by adding the primaries.
Inferences - Color Matching Experiment
400 500 600 700-0.2
0
0.2
0.4 r ( )
g( )
b ( )
negative valuestr
isim
ulus
val
ue
54
Tristimulus vales are given by The color matching in the experiment is
perceptual matching. The spectrum resulting from adding the three
primaries need not match with the spectrum of the test light.
Lights which are perceptually same but have different spectral distribution curves are called metamers
Inferences - Color Matching Experiment
r C r d g C g d b C b d ( ) ( ) ( ) ( ) ( ) ( )
55
Color Quantization
56
Image Quantization
Image quantization: discretize continuous pixel values into discrete numbers
Color resolution/ color depth/ levels: - No. of colors or gray levels or- No. of bits representing each pixel value- No. of colors or gray levels Nc is given by
bcN 2
where b = no. of bits
57
Image Quantization : Quantization function
Light intensity
Qua
ntiz
atio
n le
vel
0
1
2
Nc-1
Nc-2
Darkest Brightest
58
Effect of Quantization Levels
256 levels 128 levels
32 levels64 levels
59
Effect of Quantization Levels (cont.)
16 levels 8 levels
2 levels4 levels
In this image,it is easy to seefalse contour.
60
Introduction• Some display hardware stores 8 bits per pixel
• To display a full-color image, the computer must choose an appropriate set of representative colors and map the image into these colors
This process is called
=> it can display at most 256 distinct colors at a time
61
Quantization phases• Sample the original image for color
statistics
• Select color map based on those statistics
• Map the colors to their representative
in the color map• Redraw the image, quantizing each pixel Algorithm
Mapping…
62
The Median Cut Algorithm
• The concept – to use each of the colors in the colormap to represent an equal number of pixels in the original image
• The algorithm repeatedly subdivides color space into smaller and smaller rectangular boxes
63
The Median Cut Algorithm (cont)
• Begin with one box which tightly encloses the colors of all image pixels
R
G
B
• Repeat for every newly created box:
(a) sort enclosed points along the longest dimension of the box
(b) segregate points into two halves at the median point
• Until the desired number of boxes is generated
• Compute representative for each box by averaging the colors contained in each
64
The Median Cut Algorithm - samples
2 colors
256 colors
16 colors
4 colors
65
The Popularity Algorithm
• Run a histgoram on the entire picture to determine “pixel counts” for each color
• Pick the colors with the highest pixel count
colors
frequency
66
The Popularity Algorithm - samples
2 colors
256 colors
16 colors
4 colors
67
The Original Diversity Algorithm
• Run a histogram on the entire picture
• Pick the color with the highest pixel count
• Repeat
• Until all colors have been picked
(a) find the color in the unpicked list that is furthest from all of the colors in the picked list(b) pick this color
68
The Original Diversity Algorithm –samples
2 colors
256 colors
16 colors
4 colors
69
The Modified Diversity Algorithm
• Run a histogram on the entire picture
• The 1st color: the most popular
• The 2nd color: the furthest away from the first color• The 3rd through 10th colors: are picked using the normal Diversity Algorithm
• Repeat
(a) pick a color on popularity(b) pick a color on diversity
• Until all the colors have been picked
70
The Modified Diversity Algorithm - samples
2 colors
256 colors
16 colors
4 colors
71
Sequential Scalar Quantization
R
G• Quantize R component to some predetermined number of levels N1 according to its marginal distribution
B21 B22 B2N1
• Quantize G within each B2j to n2j
levels according to its conditional distribution (this results in a set of N2 columnar regions B3j)
B31
B32 B3N2
• Quantize B within each B3j (this results in the desired N3 = N quantization regions)
• Pick the centroid of each of the N regions as the representative for that region
x
x
x
x
x
x
xx
x
x
72
Sequential Scalar Quantization - samples
2colors
256colors
16colors
4colors
73
Generalized Lloyd Algorithm
• Consists on a number of iterations, each one recomputing the set of more appropriate partitions of the input vectors and their centroids
74
Generalized Lloyd Algorithm (cont)
• Begin with an initial data• Repeat
(a) redistribute each input vector into one of the clusters defined by their centroids
(b) recompute the centroids for each cluster just created
(c) compute the average distortion for the new centroid set
• Until the distortion has only changed by a small enough amount since the last iteration
c01 c21c11 c31
c00 c20c10 c30
image colors
representatives
75
Generalized Lloyd Algorithm - samples
original
Diversity4 colors
Diversity+ GLA
original
Popularity16 colors
Popularity+ GLA
76
Peak signal to noise ratio (PSNR)
M,N – picture dimensions
noise(i,j,k) – distance between an original
color of a pixel (located at (i,j,k)) and its color after
quantization
10*log10( Max(original image)2*3*M*N
)ΣiΣjΣk noise(i,j,k)2
PSNR(3D case) =
77
SummaryPSNR
MC P D DM SSQ
13.752
9.9089.9088.768
13.56913.752 13.745 13.75213.752
14.537
Algorithm
2 color quantization
- GLA applying- no GLA applying
MC - Median CutP - PopularityD - DiversityDM - Diversity (Modified)SSQ – Sequential Scalar Quantization
78
Summary (cont)Summary (cont)
PSNR
MC P D DM SSQ
17.197
11.23110.875
12.137
17.08518.225 18.216
18.26318.26319.053
Algorithm
4 color quantization
- GLA applying- no GLA applying
MC - Median CutP - PopularityD - DiversityDM - Diversity (Modified)SSQ – Sequential Scalar Quantization
79
Summary (cont)Summary (cont)
PSNR
MC P D DM SSQ
22.259
17.968
13.437
16.606
22.157
23.82623.056
25.856
23.21424.648
Algorithm
16 color quantization
- GLA applying- no GLA applying
MC - Median CutP - PopularityD - DiversityDM - Diversity (Modified)SSQ – Sequential Scalar Quantization
80
Summary (cont)Summary (cont)
PSNR
MC P D DM SSQ
27.12225.856
18.747
28.73531.18732.697
33.39731.606
30.333
34.042
Algorithm
256 color quantization
- GLA applying- no GLA applying
MC - Median CutP - PopularityD - DiversityDM - Diversity (Modified)SSQ – Sequential Scalar Quantization
81
CR311 HW
Mult-color edge detector:• Input a color image, img,and color
quanitzation algorithm, imgk = Q(img,k)• Create img4, img8 and img16 with 4 8 and 16
colors• Edge detect img[] with an isotropic edge
detector• Create imgSum = img4+img8+img16• Normalize imgsum and threshold, with an
adjustment.
82
New HW for CR311
Implement color quantization algorithms in the ip package using the MDI interface.• Linear cut• Median cut• Wu• Octree and NuQuant• printNumber of Colors