Color Mohi Sir
Color Mohi Sir
Mohiuddin Ahmad
EE 4235
BOOKS
https://www.mathworks.com/matlabcentral/answers/91036-how-do-i-split-a-color-image-
into-its-3-rgb-channels
3
Contents
• Introduction:
• Electromagnetic Radiation
• Spectral power distribution
• Color Spaces:
• Linear (RGB, CMYK)
• Artistic View (Munsell, HSV, HLS)
• Standard (CIE-XYZ)
• Perceptual (Luv, Lab)
• Opponent (YIQ, YUV) – used in TV
• Color Conversions
4
Ultra- Short- AC
Gamma X rays violet Infrared Radar FM TV wave AM electricity
-12 -8 -4 4 8
10 10 10 1 10 10
Wavelength in meters (m)
Visible light
0.5
0
400 500 600 700
Wavelength (λ)
6
A pigment is a material that changes the color of reflected or transmitted light as the
result of wavelength-selective absorption
7
3D Color Spaces
Brightness
black-white
G Hue
blue-yellow
B
R
red-green
10
A pigment is a material that changes the color of reflected or transmitted light as the result of wavelength-selective absorption
11
• Why?
Pigments absorb light
• Thinking:
the Color Filters
• Question:
Yellow + Cyan=?
13
RGB = x d
XYZ from Spectrum
XYZ = x d
CIE xyY from CIE XYZ
CIE xyY color model is used to catalog colors:
x = X / (X + Y + Z)
y = Y / (X + Y + Z)
Y = luminance
CIE xyY Color Cone
20
CIE-RGB
u
Z k z ( )S ( ) R( )
l
100
k u
y ( ) S ( )
l
25
111 14 126 36 12 36
36 111 36 12 17 111
200 36 1712 11136 200 14 3636 12 36
200 111 1414 36126 1217 36111 14 36
10 128 36126 36200
1711112
11136111
1414 36 17
126 111
17 36 1736 126 14127236 72200
126126 17
36111 12 36
12 17 200126 3617 12111 36200 12 126
14 200 7236 1212 17126 11117 14 36
10 128 126 200 12 111
126 200 111 14 36 72 200 36 12
36
36 14 36
111 14 126 12 36
36 12 17 72 106 155 17 36 36 14 36 72
200 111 14 126 17 111
36 111 36 12 17 111
12 17 126 17 111 200
36 36 111 36 14 36
17 111 200 36 12 36
14 200 36 12 126 17
17 126 72 126 17 111
14 36 12 36 14 36
126 200 111 14 36 72
200 36 12 36 12 126
17 111 14 126 17 111
36 72 12 12 17 17 72 111 106 14 155 36
12 126 200 36 12 36
26
B G R
Magenta – removes Green
B G R
Yellow – removes Blue
B G R
Black – removes all
27
Combining Colors
B G R
magenta
B G R
+
yellow
B G R
=
red
R
B G R
29
CMY + Black
C + M + Y = K (black)
= +
100 50 70 50 50 0 20
C M Y K C M Y
30
Example
31
Example - C
50
100
150
200
Example - M
50
100
150
200
Example - Y
50
100
150
200
Example - K
50
100
150
200
C 1 R R 1 C
M 1 G G 1 M
Y 1 B B 1 Y
36
Color Spaces
• Linear (RGB, CMYK)
• Artistic View (Munsell, HSV, HLS)
• Standard (CIE-XYZ)
• Perceptual (LUV, Lab)
• Opponent (YIQ, YUV) – used in TV
37
white
Artist’s Color
Hue
Saturation
Value
Value
• Luminance
• Dark to Light
• Value range
• High key
• Middle key
• Low key
Hue - Paint Mixing
• Physical mix of
opaque (not
transparent) paints
• Primary: RYB
• Secondary: OGV
• Neutral: R + Y + B
Hue - Ink Mixing
• Subtractive mix of
transparent inks
• Primary: CMY
• Secondary: RGB
• ~Black: C + M + Y
• Actually use CMYK
to get true black
Hue - Ink Mixing
Assumption: ink printed on pure white paper
Saturation Scale
Brightness Scale
47
HSV
Value
Saturation
Hue
48
green
120° yellow
Blue
240° magenta
0.0 H
black S
49
Color Spaces
• Linear (RGB, CMYK)
• Artistic View (Munsell, HSV, HLS)
• Standard (CIE-XYZ)
• Perceptual (Luv, Lab)
• Opponent (YIQ, YUV) – used in TV
50
X Y Z
Tristimulus values: three values that together are used to describe a color and are the amounts of
three reference colors that can be mixed to give the same visual sensation as the color considered
53
1.8
• Non negative over the visible
wavelengths.
Tristimulus values
1.4 z()
• The 3 primaries associated
with x y z spectral power y()
distribution are unrealizable 1
(negative power in some of x()
the wavelengths). 0.6
• y was chosen to equal
luminance of monochromatic 0.2
lights.
400 500 600 700
Wavelength (nm)
Tristimulus values: three values that together are used to describe a color and are the amounts of
three reference colors that can be mixed to give the same visual sensation as the color considered
54
RGB to XYZ
• RGB to XYZ is a linear transformation
Color Naming
0.9
520
530
510 540
550
505 560
green
y 500 yellow- 570
0.5 green 580
yellow
495 590
orange 600
white 610
490 cyan
pink red 650
485 magenta
blue
480
purple
470
450
0.0 0.5 1.0
x
57
0.2
0
0 0.2 0.4 0.6 0.8
59
Complementary 0.6
Wavelength - wavelength
of the spectral color which
added to the given color, 0.4
produces the reference
reference white
white.
0.2
0
0 0.2 0.4 0.6 0.8
60
Complementary 0.6
Wavelength
purity
Excitation Purity – 0.4
the ratio of the lengths
reference white
between the given color
and reference white and 0.2
between the dominant
wavelength light and
reference white. 0
Ranges between 0 .. 1. 0 0.2 0.4 0.6 0.8
61
Luminance Brightness
(intensity) vs (Lightness)
Y in XYZ V in HSV
Luminance DI2
I2
Opponent
Opponent Color Spaces
+
black-white
+
blue-yellow
- +
red-green
-
65
YUV - Example
Y U V
68
Summary
• Light Eye (Cones,Rods) [l,m,s] Color
https://www.cs.rit.edu/~ncs/color/t_convert.html
https://docs.opencv.org/3.4/de/d25/imgproc_color_conversions.html
69
Color Conversions
• RGB ↔ GRAY
• RGB ↔ CIE XYZ.Rec 709 with D65 white point
• RGB ↔ YCrCb JPEG (or YCC)
• RGB ↔ HSV
• RGB ↔ HLS
• RGB ↔ CIE L*a*b*
• RGB ↔ CIE L*u*v*
https://docs.opencv.org/3.4/de/d25/imgproc_color_conversions.html
https://www.cs.rit.edu/~ncs/color/t_convert.html
70
Color conversion
72
73
74
75
76
Question: Assignment
• Convert the following RGB image into the following image
format according to the Roll number mentioned in the next
page. The RGB values and corresponding index are
shown.
100, 200 , 220 0,50 ,90 0 , 0 , 0
• (i) RGB to Gray ( 0,0 ) ( 0 ,1) ( 0, 2 )
• (ii) RGB ↔ CIE XYZ I 80,70,40 127,127,127 255,0,255
(1, 0 ) (1,1) (1, 2 )
• (iii) RGB ↔ YCrCb 255,0,255 60,125,225 255,255,255
• (iv) RGB ↔ HSV ( 2, 0 ) ( 2 ,1) ( 0,0)
• (v) RGB ↔ HLS
• (vi) RGB ↔ CIE L*a*b*
• (vii) RGB ↔ CIE L*u*v*