Chapter 8 Chapter 8
Digital Image Processing Digital Image Processing Digital Image Processing Digital Image Processing
Colour Image Processing g g
Course Website: [Link]
2
of
76
Introduction
6
Today well look at colour image processing,
covering:
Colour fundamentals
Colour models
3
of
76
Colour Fundamentals
6
In 1666 Sir Isaac Newton discovered that
0
0
2
)
when a beam of sunlight passes through a
glass prism, the emerging beam is split into a
P
r
o
c
e
s
s
i
n
g
(
2
0
spectrum of colours
D
i
g
i
t
a
l
I
m
a
g
e
P
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
I
m
a
g
e
s
t
a
k
4
of
76
Colour Fundamentals (cont)
6
The colours that humans and most animals
perceive in an object are determined by the
nature of the light reflected from the object
For example, green
objects reflect light
with wave lengths
primarily in the range
Colours
Absorbed
of 500 570 nm while
absorbing most of the
Absorbed
energy at other
wavelengths
5
of
76
Colour Fundamentals (cont)
6
Chromatic light spans the electromagnetic
0
0
2
)
spectrum from approximately 400 to 700 nm
As we mentioned before human colour vision
P
r
o
c
e
s
s
i
n
g
(
2
0
is achieved through 6 to 7 million cones in
each eye
D
i
g
i
t
a
l
I
m
a
g
e
P
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
I
m
a
g
e
s
t
a
k
6
of
76
Colour Fundamentals (cont)
6
Approximately 66% of these cones are
sensitive to red light, 33% to green light and
6% to blue light
Absorption curves for the different cones have
been determined experimentally
Strangely these do not match the CIE
standards for red (700nm), green (546.1nm) sta da ds o ed ( 00 ), g ee (5 6 )
and blue (435.8nm) light as the standards
were developed before the experiments! e e de e oped be o e e e pe e s
7
of
76
Colour Fundamentals (cont)
6
0
0
2
)
P
r
o
c
e
s
s
i
n
g
(
2
0
D
i
g
i
t
a
l
I
m
a
g
e
P
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
I
m
a
g
e
s
t
a
k
8
of
76
Colour Fundamentals (cont)
6
3 basic qualities are used to describe the
quality of a chromatic light source: quality of a chromatic light source:
Radiance: the total amount of energy that flows
from the light source (measured in watts) from the light source (measured in watts)
Luminance: the amount of energy an observer
perceives from the light source (measured in p g (
lumens)
Note we can have high radiance, but low luminance
B i ht bj ti ( ti ll Brightness: a subjective (practically
unmeasurable) notion that embodies the
intensity of light intensity of light
Well return to these later on
9
of
76
CIE Chromacity Diagram
6
Specifying colours systematically can be
achieved using the CIE chromacity diagram
On this diagram the x-axis represents the
proportion of red and the y-axis represents the
proportion of red used
The proportion of blue used in a colour is
calculated as: ca cu ated as
z = 1 (x + y)
10
of
76
CIE Chromacity Diagram (cont)
6
0
0
2
) Green: 62% green,
P
r
o
c
e
s
s
i
n
g
(
2
0
25% red and 13%
blue
D
i
g
i
t
a
l
I
m
a
g
e
P
Red: 32% green,
67% red and 1%
a
l
e
z
&
W
o
o
d
s
,
blue
k
e
n
f
r
o
m
G
o
n
z
a
I
m
a
g
e
s
t
a
k
11
of
76
CIE Chromacity Diagram (cont)
6
Any colour located on the boundary of the
chromacity chart is fully saturated
The point of equal energy has equal amounts
of each colour and is the CIE standard for
pure white
Any straight line joining two points in the
diagram defines all of the different colours that d ag a de es a o t e d e e t co ou s t at
can be obtained by combining these two
colours additively co ou s add e y
This can be easily extended to three points
12
of
76
CIE Chromacity Diagram (cont)
6
0
0
2
)
This means the entire
l t b
P
r
o
c
e
s
s
i
n
g
(
2
0
colour range cannot be
displayed based on
any three colours
D
i
g
i
t
a
l
I
m
a
g
e
P
any three colours
The triangle shows the
typical colour gamut
a
l
e
z
&
W
o
o
d
s
,
typical colour gamut
produced by RGB
monitors
k
e
n
f
r
o
m
G
o
n
z
a
The strange shape is
the gamut achieved by
I
m
a
g
e
s
t
a
k
high quality colour
printers
13
of
76
Colour Models
6
From the previous discussion it should be
obvious that there are different ways to model
colour
We will consider two very popular models
used in colour image processing:
RGB (Red Green Blue)
HIS (Hue Saturation Intensity) ( y)
14
of
76
RGB
6
In the RGB model each colour appears in its
i t l t f d d primary spectral components of red, green and
blue
C The model is based on a Cartesian coordinate
system
G RGB values are at 3 corners
Cyan magenta and yellow are at three other corners
Bl k i t th i i Black is at the origin
White is the corner furthest from the origin
Diff t l i t i id th b Different colours are points on or inside the cube
represented by RGB vectors
15
of
76
RGB (cont)
6
0
0
2
)
P
r
o
c
e
s
s
i
n
g
(
2
0
D
i
g
i
t
a
l
I
m
a
g
e
P
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
I
m
a
g
e
s
t
a
k
16
of
76
RGB (cont)
6
Images represented in the RGB colour model
consist of three component images one for
each primary colour
When fed into a monitor these images are
combined to create a composite colour image
The number of bits used to represent each
pixel is referred to as the colour depth p e s e e ed to as t e co ou dept
A 24-bit image is often referred to as a full-
colour image as it allows = 16 777 216
3
8
2 ( )
colour image as it allows = 16,777,216
colours
2 ( )
17
of
76
RGB (cont)
6
0
0
2
)
P
r
o
c
e
s
s
i
n
g
(
2
0
D
i
g
i
t
a
l
I
m
a
g
e
P
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
I
m
a
g
e
s
t
a
k
18
of
76
The HSI Colour Model
6
RGB is useful for hardware implementations
and is serendipitously related to the way in
which the human visual system works
However, RGB is not a particularly intuitive
way in which to describe colours
Rather when people describe colours they
tend to use hue, saturation and brightness te d to use ue, satu at o a d b g t ess
RGB is great for colour generation, but HSI is
great for colour description great for colour description
19
of
76
The HSI Colour Model (cont)
6
The HSI model uses three measures to
describe colours:
Hue: A colour attribute that describes a pure
colour (pure yellow, orange or red)
Saturation: Gives a measure of how much a
l i dil t d ith hit li ht pure colour is diluted with white light
Intensity: Brightness is nearly impossible to
b it i bj ti I t d measure because it is so subjective. Instead we
use intensity. Intensity is the same achromatic
notion that we have seen in grey level images notion that we have seen in grey level images
20
of
76
HSI, Intensity & RGB
6
Intensity can be extracted from RGB images
which is not surprising if we stop to think about
it
Remember the diagonal on the RGB colour
cube that we saw previously ran from black to
white
Now consider if we stand this cube on the o co s de e sta d t s cube o t e
black vertex and position the white vertex
directly above it d ec y abo e
21
of
76
HSI, Intensity & RGB (cont)
6
0
0
2
) Now the intensity component
P
r
o
c
e
s
s
i
n
g
(
2
0
of any colour can be
determined by passing a
D
i
g
i
t
a
l
I
m
a
g
e
P
plane perpendicular to
the intenisty axis and
a
l
e
z
&
W
o
o
d
s
,
containing the colour
point
k
e
n
f
r
o
m
G
o
n
z
a
The intersection of the plane
with the intensity axis gives us the intensity
I
m
a
g
e
s
t
a
k
component of the colour
22
of
76
HSI, Hue & RGB
6
In a similar way we can extract the hue from
0
0
2
)
the RGB colour cube
Consider a plane defined by
P
r
o
c
e
s
s
i
n
g
(
2
0
the three points cyan, black
and white
D
i
g
i
t
a
l
I
m
a
g
e
P
All points contained in
this plane must have the a
l
e
z
&
W
o
o
d
s
,
t s p a e ust a e t e
same hue (cyan) as black
and white cannot contribute
k
e
n
f
r
o
m
G
o
n
z
a
a d e ca o co bu e
hue information to a colour
I
m
a
g
e
s
t
a
k
23
of
76
The HSI Colour Model
6
0
0
2
)
Consider if we look straight down at the RGB
b i d i l
P
r
o
c
e
s
s
i
n
g
(
2
0
cube as it was arranged previously
We would see a hexagonal
D
i
g
i
t
a
l
I
m
a
g
e
P
shape with each primary
colour separated by 120
a
l
e
z
&
W
o
o
d
s
,
and secondary colours
at 60from the primaries
k
e
n
f
r
o
m
G
o
n
z
a
So the HSI model is
composed of a vertical
I
m
a
g
e
s
t
a
k
intensity axis and the locus of colour points that
lie on planes perpendicular to that axis
24
of
76
The HSI Colour Model (cont)
6
0
0
2
)
To the right we see a hexagonal
h d bi l
P
r
o
c
e
s
s
i
n
g
(
2
0
shape and an arbitrary colour
point
D
i
g
i
t
a
l
I
m
a
g
e
P
The hue is determined by an
angle from a reference point,
usually red
a
l
e
z
&
W
o
o
d
s
,
usually red
The saturation is the distance from the origin to the
point
k
e
n
f
r
o
m
G
o
n
z
a
point
The intensity is determined by how far up the
vertical intenisty axis this hexagonal plane sits (not
I
m
a
g
e
s
t
a
k
y g p (
apparent from this diagram
25
of
76
The HSI Colour Model (cont)
6
0
0
2
)
Because the only important things are the angle
d h l h f h i hi
P
r
o
c
e
s
s
i
n
g
(
2
0
and the length of the saturation vector this
plane is also often represented as a circle or a
t i l
D
i
g
i
t
a
l
I
m
a
g
e
P
triangle
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
I
m
a
g
e
s
t
a
k
26
of
76
HSI Model Examples
6
0
0
2
)
P
r
o
c
e
s
s
i
n
g
(
2
0
D
i
g
i
t
a
l
I
m
a
g
e
P
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
I
m
a
g
e
s
t
a
k
27
of
76
HSI Model Examples
6
0
0
2
)
P
r
o
c
e
s
s
i
n
g
(
2
0
D
i
g
i
t
a
l
I
m
a
g
e
P
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
I
m
a
g
e
s
t
a
k
28
of
76
Converting From RGB To HSI
6
Given a colour as R, G, and B its H, S, and I
values are calculated as follows:
H
u if B s G
u
1
1
2
RG
( )
+ R B
( )
| |
`
H =
f
360 u if B > G
u = cos
1 2
( ) ( )
| |
RG
( )
2
+ R B
( )
G B
( )
| |
1
2
)
S =1
3
R+ G+ B
( )
min R,G, B
( )
| |
I =
1
3
R+ G+ B
( )
( )
29
of
76
Converting From HSI To RGB
6
Given a colour as H, S, and I its R, G, and B
values are calculated as follows:
RG sector (0 <= H < 120)
G = 3I R+ B
( )
B = I 1 S
( )
R = I 1+
ScosH
cos 60 H
( )
(
(
GB sector (120<= H < 240)
cos 60 H
( )
( )
B = 3I R+ G
( )
R = I 1 S
( )
G = I 1+
Scos H 120
( )
H 60
( )
(
( ( ) ( )
cos H 60
( )
30
of
76
Converting From HSI To RGB (cont)
6
BR sector (240<= H <= 360)
R = 3I G+ B
( )
G = I 1 S
( )
B = I 1+
Scos H 240
( )
cos H 180
( )
(
(
( )
31
of
76
HSI & RGB
6
0
0
2
)
P
r
o
c
e
s
s
i
n
g
(
2
0
RGB Colour Cube
D
i
g
i
t
a
l
I
m
a
g
e
P
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
I
m
a
g
e
s
t
a
k
H, S, and I Components of RGB Colour Cube
32
of
76
Manipulating Images In The HSI Model
6
In order to manipulate an image under the HIS
model we:
First convert it from RGB to HIS
Perform our manipulations under HSI
Finally convert the image back from HSI to RGB
RGB
HSI Image
RGB
Image
HSI Image
Image
Manipulations Manipulations
33
of
76
RGB -> HSI -> RGB
6
0
0
2
)
P
r
o
c
e
s
s
i
n
g
(
2
0
RGB
Image
Hue
D
i
g
i
t
a
l
I
m
a
g
e
P
g
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
Saturation Intensity
I
m
a
g
e
s
t
a
k
34
of
76
RGB -> HSI -> RGB (cont)
6
0
0
2
)
P
r
o
c
e
s
s
i
n
g
(
2
0
Hue
Saturation
D
i
g
i
t
a
l
I
m
a
g
e
P
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
Intensity RGB
Image
I
m
a
g
e
s
t
a
k
35
of
76
Pseudocolour Image Processing
6
Pseudocolour (also called false
colour) image processing consists
of assigning colours to grey values
based on a specific criterion
The principle use of pseudocolour
image processing is for human
visualisation
Humans can discern between
thousands of colour shades and
intensities, compared to only about
two dozen or so shades of grey
36
of
76
Pseudo Colour Image Processing
Intensity Slicing
6
Intensity Slicing
Intensity slicing and colour coding is one of the
i l ki d f d l i simplest kinds of pseudocolour image
processing
First we consider an image as a 3D function
mapping spatial coordinates to intensities (that
we can consider heights)
Now consider placing planes at certain levels
parallel to the coordinate plane
If a value is one side of such a plane it is p
rendered in one colour, and a different colour if
on the other side
37
of
76
Pseudocolour Image Processing
Intensity Slicing (cont )
6
Intensity Slicing (cont)
0
0
2
)
P
r
o
c
e
s
s
i
n
g
(
2
0
D
i
g
i
t
a
l
I
m
a
g
e
P
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
I
m
a
g
e
s
t
a
k
38
of
76
Pseudocolour Image Processing
Intensity Slicing (cont )
6
Intensity Slicing (cont)
In general intensity slicing can be summarised
as:
Let [0, L-1] represent the grey scale
Let l
0
represent black [f(x, y) = 0] and let l
L-1
represent white [f(x, y) = L-1]
Suppose P planes perpendicular to the intensity
axis are defined at levels l
1,
l
2, ,
l
p
Assuming that 0 < P < L-1 then the P planes
partition the grey scale into P + 1 intervals V
1
,
V V V
2
,,V
P+1
39
of
76
Pseudocolour Image Processing
Intensity Slicing (cont )
6
Intensity Slicing (cont)
Grey level colour assignments can then be made
di t th l ti according to the relation:
h k i th l i t d ith th k
th
f (x, y) = c
k
if f (x, y) eV
k
where ck is the colour associated with the k
th
intensity level V
k
defined by the partitioning
planes at l = k 1 and l = k planes at l = k 1 and l = k
40
of
76
RGB -> HSI -> RGB (cont)
6
0
0
2
)
P
r
o
c
e
s
s
i
n
g
(
2
0
D
i
g
i
t
a
l
I
m
a
g
e
P
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
I
m
a
g
e
s
t
a
k
41
of
76
RGB -> HSI -> RGB (cont)
6
0
0
2
)
P
r
o
c
e
s
s
i
n
g
(
2
0
D
i
g
i
t
a
l
I
m
a
g
e
P
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
I
m
a
g
e
s
t
a
k
42
of
76
RGB -> HSI -> RGB (cont)
6
0
0
2
)
P
r
o
c
e
s
s
i
n
g
(
2
0
D
i
g
i
t
a
l
I
m
a
g
e
P
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
I
m
a
g
e
s
t
a
k
43
of
76
RGB -> HSI -> RGB (cont)
6
0
0
2
)
P
r
o
c
e
s
s
i
n
g
(
2
0
D
i
g
i
t
a
l
I
m
a
g
e
P
a
l
e
z
&
W
o
o
d
s
,
k
e
n
f
r
o
m
G
o
n
z
a
I
m
a
g
e
s
t
a
k
44
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
45
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
46
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
47
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
48
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
49
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
50
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
51
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
52
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
53
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
54
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
55
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
56
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
57
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
58
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
59
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
60
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
61
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
62
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
63
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
64
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
65
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
66
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
67
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
68
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
69
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
70
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
71
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
72
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
73
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
74
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
75
of
76
Chapt er 8
Color I mage Processing
Chapt er 8
Color I mage Processing
6
Color I mage Processing Color I mage Processing
76
of
76
Questions?
6