Chapter 6 - Color Image Processing
Chapter 6 - Color Image Processing
Dr J. Shanbehzadeh
[email protected]
Table of Contents
6.1 Color Fundamentals
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
1
6.1 Color Fundamentals
2
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
Light
ends abruptly
no color in the spectrum
Infrared
3
Three basic quantities to describe the quality of a
chromatic light source are:
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
4
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
5
Primary & Secondary Colors of Light
Additive primary colors: RGB
use in the case of light sources
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
6
Characteristics of Colors
The characteristics generally used to distinguish one
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
Brightness
saturation Hue
7
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
Brightness(Intensity)
Brightness embody the achromatic notion of intensity.
8
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
Hue
wavelength of mixture light wave
dominant color corresponding to a dominant
9
Saturation
Relative purity or amount of white light mixed with a
hue.
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
10
Radiance, Luminance, Brightness
Three basic properties used to describe the quality of
chromatic light source:
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
Luminance
Radiance
Brightness
11
Chromaticity
Saturation + Hue = chromaticity
amount of red (X), green (Y) and blue (Z) to form any particular color
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
is called tristimulus.
CIE Chromaticity Diagram Trichromatic coefficients:
X
x
X Y Z
Y
y
y X Y Z
Z
z
X Y Z
x y z 1
x 12
Chromaticity
CIE chromaticity diagram
• Has superior performance over other color transforms
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
13
Color Gamut of Color Monitors and Printing Devices
A triangle with vertices at any three fixed colors cannot enclose the entire color region
it shows that not all colors can be obtained with three single, fixed primaries.
Color
Monitors
Printing
devices
14
6.2 Color Models
6.2.1 The RGB Color Model
6.2.2 The CMY and CMYK Color Model
6.2.3 The HSI Color Model
15
Color Space or Color System
Purpose of color models: to facilitate the specification of colors
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
in some standard.
A specification of a coordinate system and a subspace within that
system where each color is represented a single point
Two applied directions for color models:
Hardware
Applications where color manipulation(color graphics)
Color Models:
RGB models: color monitors
CMY (CMYK): color model for color printing
YIQ: Color model for color television
HIS: a color model for humans to describe and to interpret color;
decouple the color and gray-level information.
16
6.2 Color Models
6.2.1 The RGB Color Model
6.2.2 The CMY and CMYK Color Model
6.2.3 The HSI Color Model
17
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
18
6.2 Color Models
6.2.1 The RGB Color Model
6.2.2 The CMY and CMYK Color Model
6.2.3 The HSI Color Model
19
CYM & CYMK Color Models
Color printer and copier
Deposit colored pigment
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
on paper
Relationship with RGB
model:
C 1 R C = Cyan
M 1 G M = Magenta
Y = Yellow
Y 1 B K = Black
Example :surface coated with pure cyan does not contain red (C = 1 — R)
20
6.2 Color Models
6.2.1 The RGB Color Model
6.2.2 The CMY and CMYK Color Model
6.2.3 The HSI Color Model
21
HSI Color Model
RGB, CMY models are not good for human interpreting
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
22
Conceptual relationships between
RGB & HSI models
extract intensity from an RGB image : the line (intensity
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
23
Conceptual relationships between
RGB & HIS models
saturation : increases as a function of distance from the
intensity axis .
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
24
Conceptual relationships between
RGB & HIS models
white yellow
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
cyan green
saturation
red
blue
black
The triangle is hue
intensity
25
HSI & Saturation on Color Planes
Hue is an angle from a red axis. Origin is defined by the
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
26
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
RGB
HSI
Relationship Between RGB and HSI Color Models
27
Converting Colors from RGB to HSI
if B G
H RGB
360 if B G
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
1
( R G ) ( R B )
cos1 2
1/ 2
( R G ) ( R B )(G B )
2
Hue
3
S 1
RG B
saturation
1
I ( R G B)
3
Intensity
28
Converting Colors from HSI to RGB
RG sector: 0 H 120 GB sector: 120 H 240
H H 120
S cos H
R I 1 R I (1 S )
cos( 60
H )
B I (1 S ) S cos H
G I 1
cos( 60
H )
G 1 ( R B)
B 1 ( R G)
BR sector: 240 H 360
H H 240
S cos H
B I 1
cos( 60
H )
G I (1 S )
R 1 (G B) 29
Example: HSI Components of RGB Cube
every pixel in the intensity is the average of the RGB
values at the corresponding pixel in Fig. 6.8.
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
RGB Cube
RGB
Image
Saturation
Hue
Intensity
31
Example: HSI Components of RGB Colors
Example: Manipulating HSI Components
RGB
Image Hue Hue Saturation
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
Saturation : reduced by half the saturation of the cyan region in component image S
Intensity : reduced by half the intensity of the central white region in the intensity image
32
6.3 Pseducolor Image Processing
6.3.1 Intensity Slicing
6.3.2 Intensity to Color Transformations
33
Color Image Processing
There are 2 types of color image processes:
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
34
Pseudocolor Image Processing
Differentiate the process of assigning colors to monochrome images
from the process associated with true color images.
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
35
6.3 Pseducolor Image Processing
6.3.1 Intensity Slicing :
used in analysis of remotely sensed imagery to enhance the information
gathered from an individual brightness band.
is done by dividing the range of brightnesses in a single band into
intervals, then assigning each interval to a color
6.3.2 Intensity to Color Transformations
36
Intensity Slicing or Density Slicing
Formula:
C1 if f ( x, y ) T C1 = Color No. 1
g ( x, y )
C2 if f ( x, y ) T C2 = Color No. 2
Color
T C2
C1
0 T L-1
Intensity
A gray scale image viewed as a 3D surface.
37
Intensity Slicing Example
38
Multi Level Intensity Slicing
g ( x, y ) Ck for lk 1 f ( x, y ) lk
Ck = Color No. k
lk = Threshold level k
Color
Ck
Ck-1
C3
C2
C
1
0 l1 l2 l3 lk-1 lk
L-1
Intensity
39
Multi Level Intensity Slicing Example
Ck = Color No. k
g ( x, y ) Ck for lk 1 f ( x, y ) lk lk = Threshold level k
40
Color Coding Example
A unique color is assigned to
each intensity value.
Color
map
42
Gray Level to Color Transformation
Red component
Blue component
43
Gray Level to Color Transformation Example
An X-ray image An X-ray image of a
of a garment bag garment bag with a
simulated explosive
device
Transformations
Color
coded
images
44
Gray Level to Color Transformation Example
Color
Transformations coded
images
45
Pseudocolor Coding
46
Pseudocolor Coding Example
Visible blue Visible green
= 0.45-0.52 mm = 0.52-0.60 mm
Max water penetration Measuring plant Color composite images
1 2
3 4 Red = 1 Red = 1
Green = 2 Green = 2
Blue = 3 Blue = 4
Psuedocolor rendition
of Jupiter moon Io
A close-up
48
6.4 Basics of Full-Color
Image Processing
2 Methods:
1. Per-color-component processing: process each
component separately.
2. Vector processing: treat each pixel as a vector to be
processed.
49
Basics of Full-Color Image Processing
50
6.5 Color Transformations
6.5.1 Formulation
6.5.2 Color Complements
6.5.3 Color Slicing
6.5.4 Tone and Color Corrections
6.5.5 Histogram Processing
51
6.5 Color Transformations
6.5.1 Formulation
6.5.2 Color Complements
6.5.3 Color Slicing
6.5.4 Tone and Color Corrections
6.5.5 Histogram Processing
52
Formulation
Use to transform colors to colors.
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
Formulation:
g ( x, y ) T f ( x, y )
f(x,y) = input color image, g(x,y) = output color image
T = operation on f over a spatial neighborhood of (x,y)
Color image
CMYK components
RGB components
HSI components
54
Example: Color Transformation
Formula for RGB:
sR ( x, y ) krR ( x, y )
sG ( x, y ) krG ( x, y )
sB ( x, y ) krB ( x, y )
sC ( x, y ) krC ( x, y ) (1 k )
sM ( x, y ) krM ( x, y ) (1 k ) These 3 transformations give
sY ( x, y ) krY ( x, y ) (1 k ) the same results.
55
6.5 Color Transformations
6.5.1 Formulation
6.5.2 Color Complements
6.5.3 Color Slicing
6.5.4 Tone and Color Corrections
6.5.5 Histogram Processing
56
Color Complements
Color complement replaces each color with its opposite color in the
color circle of the Hue component. This operation is analogous to
image negative in a gray scale image.
Color circle
57
Color Complement Transformation Example
58
6.5 Color Transformations
6.5.1 Formulation
6.5.2 Color Complements
6.5.3 Color Slicing
6.5.4 Tone and Color Corrections
6.5.5 Histogram Processing
59
Color Slicing Transformation
W
0.5 if rj a j Set to gray
si 2 any 1 j n
ri otherwise Keep the original
i= 1, 2, …, n color
or
0.5 if rj a j R0
n
2 2 Set to gray
si j 1
ri otherwise Keep the original
color
i= 1, 2, …, n
60
Color Slicing Transformation Example
Original image
61
6.5 Color Transformations
6.5.1 Formulation
6.5.2 Color Complements
6.5.3 Color Slicing
6.5.4 Tone and Color Corrections
6.5.5 Histogram Processing
62
Tonal Correction Examples
In these examples, only
brightness and contrast are
adjusted while keeping color
unchanged.
This can be done by
using the same transformation
for all RGB components.
Contrast enhancement
63
Color Balancing Correction Examples
Color imbalance: primary color components in white area
are not balance. We can measure these components by
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
64
6.5 Color Transformations
6.5.1 Formulation
6.5.2 Color Complements
6.5.3 Color Slicing
6.5.4 Tone and Color Corrections
6.5.5 Histogram Processing
65
Histogram Equalization of a Full-Color Image
Histogram equalization of a color image can be
performed by adjusting color intensity uniformly
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
66
Histogram Equalization of a Full-Color Image
Original image
67
6.6 Smoothing and Sharpening
6.6.1 Color Image Smoothing
6.6.2 Color Image Sharpening
68
6.6 Smoothing and Sharpening
6.6.1 Color Image Smoothing
6.6.2 Color Image Sharpening
69
Color Image Smoothing
2 Methods:
1. Per-color-plane method: for RGB, CMY color models
Smooth each color plane using moving averaging and
the combine back to RGB
1
R ( x, y )
K ( x , y )S xy
1 1
c ( x, y ) c( x, y )
K ( x , y )S xy
G ( x, y )
K ( x , y )S xy
1
K ( x , B ( x , y )
y )S xy
Green Blue
71
Color Image Smoothing Example (cont.)
Color image
HSI Components
72
Color Image Smoothing Example (cont.)
73
Color Image Smoothing Example (cont.)
Difference between
smoothed results from 2
methods in the previous
slide.
74
6.6 Smoothing and Sharpening
6.6.1 Color Image Smoothing
6.6.2 Color Image Sharpening
75
Color Image Sharpening
We can do in the same manner as color image smoothing:
1. Per-color-plane method for RGB,CMY images
2. Sharpening only I component of a HSI image
Difference between
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
sharpened results
from 2
methods in the
previous
slide.
77
6.7 Image Segmentation Based on
Color
6.7.1 Segmentation in HIS Color Space
6.7.2 Segmentation in RGB Vector Space
6.7.3 Color Edge Detection
78
Color Segmentation
2 Methods:
1. Segmented in HSI color space:
A thresholding function based on color information in H and S
Components. We rarely use I component for color image
segmentation.
79
6.7 Image Segmentation Based on
Color
6.7.1 Segmentation in HIS Color Space
6.7.2 Segmentation in RGB Vector Space
6.7.3 Color Edge Detection
80
Color Segmentation in HSI Color Space
Color image Hue
1 2
3 4
Saturation Intensity
81
Color Segmentation in HSI Color Space (cont.)
Binary thresholding of S component Product of 2 and 5
with T = 10%
5 6
Red pixels
7 8
Histogram of 6 Segmentation of red color pixels 82
Color Segmentation in HSI Color Space (cont.)
83
6.7 Image Segmentation Based on
Color
6.7.1 Segmentation in HIS Color Space
6.7.2 Segmentation in RGB Vector Space
6.7.3 Color Edge Detection
84
Color Segmentation in RGB Vector Space
1 if D (c( x, y ), cT ) T
g ( x, y )
0 if D (c( x, y ), cT ) T
cT = color to be segmented.
D(u,v) = distance function c(x,y) = RGB vector at pixel (x,y).
85
Example: Segmentation in RGB Vector Space
Color image
Results of segmentation in
RGB vector space with Threshold
value
T = 1.25 times the SD of R,G,B values
In the box
86
6.7 Image Segmentation Based on
Color
6.7.1 Segmentation in HIS Color Space
6.7.2 Segmentation in RGB Vector Space
6.7.3 Color Edge Detection
87
Gradient of a Color Image
Since gradient is define only for a scalar image, there is no concept
of gradient for a color image. We can’t compute gradient of each
color component and combine the results to get the gradient of a color
image.
Red Green Blue We see
2 objects.
We see
4 objects.
Edges
88
Gradient of a Color Image (cont.)
One way to compute the maximum rate of change of a color image
which is close to the meaning of gradient is to use the following
formula: Gradient computed in RGB color space:
1
1
F ( ) ( g xx g yy ) ( g xx g yy ) cos 2 2 g xy sin 2
2
2
1 1 2 g xy
tan
2
xx
g g
yy
2 2 2
R G B R G B
2 2 2
g xx g yy
x x x y y y
R R G G B B
g xy
x y x y x y
89
Gradient of a Color Image Example
2
Sum of
gradients of Difference
each color between
component 22 and 33
90
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
Red
Green
91
6.8 Noise in Color Images
92
Noise in Color Images
Noise can corrupt each color component independently.
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
Noise is less
noticeable
AWGN sh2=800 in a color
image
93
R. C. Gonzalez, and R. E. Woods, Digital Image Processing, New Jersey: Prentice Hall, 3 rd edition, 2008.
Hue
Saturation
Noise in Color Images
Intensity
94
Noise in Color Images
Salt & pepper noise Hue
in Green component
Saturation Intensity
95
6.9 Color Image Compression
96
Color Image Compression
Original image
JPEG2000 File