Block 2
Block 2
UNIT 5
IMAGE TRANSFORMATIONS-
FREQUENCY DOMAIN
5.1 INTRODUCTION
As we saw in Unit 2, an image can be transformed, to show or hide
information in the image. Image transformations can be done in both the
spatial and the frequency domain. In the spatial domain, image
transformation is carried out by changing the value of the pixels based
on certain constraints. These transformations can change the
brightness and clarity of the images.
53
Block 2 DIGITAL IMAGE PROCESSING-II
In Sec. 5.2, we shall focus on very important and useful image
transformations, namely the Discrete Fourier transformation (DFT). We
shall continue our discussion in Sec. 5.3 with the Discrete Cosine
Transformation (DCT). Subsequently, Discrete Wavelet Transform will
be discussed in Sec. 5.4 Thereafter, In Sec. 5.5, Haar transform will be
discussed . As we go through this unit, we shall see the unique
properties of each of these transforms.
Now we shall list the objectives of this unit. After going through the unit,
please read this list again and make sure that you have achieved the
objectives.
Objectives
After studying this unit you should be able to:
Then,
N 1 x
1 i 2 N
g (u ) e f ( x ); u 0,1, 2,...N 1 (2)
x 0 N
N 1 i 2 u x
f (x ) e N
g(u ) (3)
x 0
M 1 N 1 ux vy
i 2
F(u, v) f ( x, y)e M N
(4)
x 0 y 0
ux vy
1 M 1 N 1 i 2
f ( x , y)
MN u 0 v 0
F( u , v ) e M N
(5)
Note that while the image values f ( x, y) are going to be real, the
corresponding frequency domain data is going to be complex. There will
be one matrix containing real values R ( u , v) and the other matrix I( u , v)
will contain the imaginary component of the complex value. The
amplitude spectrum or the magnitude for 2D DFT is given by
F( u , v) [ R 2 ( u , v) I 2 ( u , v)]1 / 2 (6)
55
Block 2 DIGITAL IMAGE PROCESSING-II
where, R and I are real and imaginary parts of F( u , v) and and all
computations are carried out for the discrete variables u 0,1, 2, ..., M 1
and v 0,1, 2, ..., N 1. The spectrum tells us the relative magnitude at
each frequency.
Note that the size of the image remains the same as the original image
in spatial domain.Therefore, the magnitude, Fourier (phase) spectrum
andthe power spectrum are all matrices of size M N.
M 1 2 i u x
F( x, v) e M
,
x 0
N 1 2 i vy
where F( x, v) f ( x, y) e N
.
y 0
Also, the 2-D DFT can also be found using the Eqn. (4) with the
condition of separability as we used in Unit-2.
1 M 1 N 1
f ( x , y) f ( x, y)
MN x 0 y 0
1 M 1 N 1
If we see the value of F(0, 0) f (x , y) F(0,0) f (x, y) .
MN x 0 y0
Fig. 1: Rotation in f ( x , y)
Fig. 1 shows how the rotation in the spatial domain (on left) affects the
rotation in the frequency domain (right).
After going through all the properties of DFT, let us see how do we
visualize 2-D DFT. We need to translate the origin of the transformed
image to the center of the image (u , v) (M / 2, N / 2) to be able to
display the full period of the 2-D DFT. As we saw above, translating
the Fourier image to the center, requires us to use the translation
property of F( u , v) with u 0 M / 2 and v 0 N / 2.
57
Block 2 DIGITAL IMAGE PROCESSING
PROCESSING-II
i 2 0 0
xu yv
Then, Ff (x, y) e M N F(u u 0 , v v 0 ) becomes
F{f ( x , y )e i ( x y ) } F{f ( x , y) ( 1) ( x y ) } F( u M / 2, v N / 2)
We can see in Fig. 2 what changes do we see after DFT. Fig 2. (a) is
the original image in the spatial domain, (b) is the 2-D DFT image, and
(c) is the translated DFT image to show the full period of the 2D DFT of
image in (a).
1
[f (0)(i) 0 f (10( i) u f ( 2)(i) 2 u f (3)(i) 3u ]; u 0,.1, 2, 3
4
1
[1 0 ( 1)(i) 2 u 0]; u 0,1, 2, 3
4
1
[1 (i) 2 u ]; u 0,1, 2, 3
4
1
This gives g [0, 2, 0, 2], which is the DFT of f ( x ).
4
***
Example 2: Construct a DFT matrix of order 2.
Solution: Here N 2.
i . 2 . ux
1 1
g(u ) f (x ) e
2 x 0
2
; u 0,1.
1 1
2 x 0
f ( x ) (1) ux ; u 0,1
1
[f (0)( 1) 0 f (1) (1) u ]; u 0,1
2
1
[f (0) ( 1) u f (1); u 0,1
2
1
Now, g(0) [f (0) f (1)]
2
1
g (1) [f (0) f (1)]
2
1 1 1
DFT matrix .
2 1 1
***
Example 3: Compute the 2-D DFT of the 2 2 image
59
Block 2 DIGITAL IMAGE PROCESSING-II
1 1
f ( x , y) .
1 1
1 1 ux vy
2 i
F(u, v) f ( x, y) e 2 2
; u, v 0, 1
x 0 y 0
1 1
f ( x, y) (1) ux ( 1) vy ; u , v 0, 1
x 0 y 0
4 0
Thus, the 2-D DFT of the given image is .
0 0
F(0,0) is 4 which happens to be the average of all the intensity values in
original image. The other values represent frequency values. But since
there is no variation in values of original image, there is no frequency
involved, and that is why the frequency values in DFT are zeroes.
Alternatively, the 2-D DFT can also be found using the DFT basis matrix
formed by finding 1-D DFT of each row of f ( x , y) and then using that as
kernel.
Therefore,
1 1
kernel
1 1
1
[we are skipping as in 2-D we
1 1 1 1 1 1 2
Hence, F(u, v)
1 1 1 1 1 1 have taken
1
in inverse DFT]
MN
2 2 1 1
0 0 1 1
4 0
0 0
60 Both the results are same.
Unit 5 Image Transformations – Frequency Domain
***
Try the following exercises.
Let us visualize the effect of 1-D DCT through Fig. 4, where in the rows
of the 8 8 transformation matrix of the DCT for a signal f ( x ) with 8
samples are shown.
61
Block 2 DIGITAL IMAGE PROCESSING-II
The figures for values of u from 0 to 7 show the various rows of the 8 8
transformation matrix of the DCT for a 1D signal f ( x ) with 8 samples.
DCT and DFT are very similar, however, DCT has the advantage over
DFT that DCT is real while DFT is complex. Moreover. DCT has better
energy compaction in comparison to the energy compaction of DFT.
Energy compaction is the ability to pack the energy of the spatial
sequence into as few frequency coefficients as possible. This property
is exploited for image compression and is a very important property.You
can see in the Fig.5, that most of the DCT image is dark, which means
DCT values are concentrated only in few pixels very near the origin.
This indicates that DCT has high compaction.
Fig.5: The 2D DCT in (b) of the image Lena in (a) shows the high compaction
capability of DCT.
62
Unit 5 Image Transformations – Frequency Domain
Example 4: Compute the discrete cosine transform (DCT) matrix for
order 2.
1
(2 x 1) u
C(u ) a (u ) f ( x ) cos ; 0 u 1.
x 0 2 2
1
2 ; u0
where a ( u )
2 1; u 1
2
At u 0, we get
1 1 (2 x 1) 0
C ( 0)
2 x 0
f ( x ) cos
4
1
1
f (x ) 1
2 x 0
1 1
f (x)
2 x 0
1
[f (0) f (1)]
2
At u 1, we get
1
(2 x 1) 1
C(1) 1 f ( x ) cos
x 0 4
1
(2x 1)
f ( x ) cos
x 0 4
3
f (0) cos f (1) cos
4 4
1 1
f ( 0) f (1)
2 2
63
Block 2 DIGITAL IMAGE PROCESSING-II
So far, we have discussed discrete fourier transform and discrete
cosine transform.
5.4 DISCRETE WAVELET TRANSFORM
Also, we learned that Fourier transform is a powerful tool that has been
available to signal analysts for many years. It gives information
regarding the frequency content of a signal. However, the problem with
using Fourier transforms is that frequency analysis cannot offer both
good frequency and time resolution at the same time. A Fourier
transform does not give information about the time at which a particular
frequency has occurred in the signal. Hence, a Fourier transform is not
an effective tool to analyse a non-stationary signal. To overcome this
problem, windowed Fourier transform, or short-time Fourier transform,
was introduced. Even though a short-time Fourier transform has the
ability to provide time information, multi-resolution is not possible with
short-time Fourier transforms. Wavelet is the answer to the multi-
resolution problem. A wavelet has the important property of not having a
fixed-width sampling window.
64
Unit 5 Image Transformations – Frequency Domain
The technique of wavelet transformation, which is typically utilised for
the analysis of images and the compression of data, will be investigated
in this section. In spite of the fact that the frequency domain
encompasses a number of other mathematical transformations,
including the Fourier transform, the Laplace transform, and the Z
transform, the wavelet transformation method is going to be the one that
is discussed in detail in this section.
Let’s try to understand this concept of wavelet in a better way, with the
explanation given below:
A wavelet is a wave-like oscillation that is localised in time; an example
of this type of oscillation is provided further down in this paragraph.
Scale and location are the two fundamental features that wavelets
possess. How "stretched" or "squished" a wavelet is can be defined by
its scale, which can also be referred to as its dilation. This characteristic
is connected to frequency in the sense that it is understood for waves.
The wavelet's position in time can be determined based on its location
(or space).
Generally, got confused for waves and wavelets but they are different
the fundamental difference between the two is that a wave is an
oscillating function of time or space that is periodic. The wave is an
infinite length continuous function in time or space. In contrast, wavelets
are localised waves. A wavelet is a waveform of an effectively limited
duration that has an average value of zero.
A function () can be called a wavelet if it posses the following properties:
1. The function integrates to zero, or equivalently its Fourier transform
denoted as ψ(ω) is zero at the
onigin:
∞
∫ ∞ ψ(x)dx = 0 (12a)
So, the wavelet transform can be broadly classified into (i) continuous
wavelet transform, and (ii) discrete wavelet transform. For long signals,
continuous wavelet transform can be time consuming since it needs to
integrate over all times. To overcome the time complexity, discrete
wavelet transform was introduced. Discrete wavelet transforms can be
implemented through sub-band coding. The DWT is useful in image
processing because it can simultaneously localise signals in time and
scale, whereas the DFT or DCT can localise signals only in the
frequency domain. 67
Block 2 DIGITAL IMAGE PROCESSING-II
It is to be noted that apart from image processing, the DWT is quite
promising tool for the Signal processing also. After the suggestion of
Mallat's, that signals may be represented at several resolutions using
wavelet decomposition, Discrete Wavelet Transform (DWT) emerged as
an extremely flexible tool for signal processing. Because the energy of
wavelets is concentrated in time while still retaining the wave-like
(periodic) characteristics, we discovered that wavelets make it possible
to perform time and frequency analysis of signals at the same time. This
was one of the key takeaways from the investigation into wavelets. As a
consequence of this, wavelet representation offers a flexible
mathematical tool for the analysis of transient, time-variant (non-
stationary), signals that are not statistically predictable, particularly in
the region of discontinuities. This quality is characteristic of images that
have discontinuities at the edges. In DWT, a digital signal splits up into
its component sub-bands, so that the lower frequency sub-bands have
finer frequency resolution and coarser time resolution compared to the
higher frequency sub-bands. .
The first significant benefit is one that we have gone over in some detail
already. This is most likely the most important advantage of utilising the
Wavelet Transform. This may be preferable to employing a method
such as a Short-Time Fourier Transform, which needs slicing a signal
into segments and then applying a Fourier Transform to each individual
segment.
Important points:
For example, when N 4, k will take the values k 0,1, 2, 3. For these
the corresponding values of p and q have to satisfy that k 2 p q 1.
0 1 N 1
Let t take the values from the set , ,..., .
N N N
Then, the Haar basis functions are recursively defined as:
For k 0, the Haar function is defined as a constant
h 0 (t) 1/ N (14)
70
Unit 5 Image Transformations – Frequency Domain
p/2 (q 1) (q 0.5)
2 ; p
t
2 2p
1 p/ 2 (q 0.5) q
h k (t ) 2 ; p
t p (15)
N 2 2
0 ; othewise
As can be seen from the definition of the Haar basis functions, for the
non-zero part of the function, the amplitude and width is determined by
p while its position is determined by q.
p 0 0
q 0 1
k 0 1
1
for k 0, h 0 ( t ) [using Eqn. (14)]
2
1 1 ;t0
for k 1, h, ( t )
2 1 ; t 1 / 2
1 1 1
Thus, Haar transform is h 2 .
2 1 1
***
Example 6: For N 8, the 8 8 discrete Haar transform matrix.
Solution:As you know we need to find various parameters of Haar
transform. So, we find them as follows:
i) Here N 8,
ii) N 2n n 3
iii) when p 0, q 0,1
p 1, q 1, 2
p 2, q 1, 2, 3, 4
iv) All the possible values of k for each set of p and q are given below:
p 0 0 1 1 2 2 2 2
q 0 1 1 2 1 2 3 4
71
Block 2 DIGITAL IMAGE PROCESSING-II
k 0 1 2 3 4 5 6 7
1 2 3 4 5 6 7
v) Accordingly, t 0, , , , , , , .
8 8 8 8 8 8 8
Now, we compute h k ( t ) for each k and t .
For k 0, h 0 ( t ) 0. for all t .
p / 2 q 1 q 0.5
2 ; 2p t 2p
1 p / 2 q 0.5 q
In general, h k ( t ) 2 ; p
t p . (16)
8 2 2
0 ; otherwise
Now, let us find each h k ( t ) for each of the interval of t for a particular k
using Eqn. (16) in the following table:
For k 1
Parameters h k (t) Haar Transform
k, q, p after
simplification
k 1, 0 1 0.5 1 1
1; 2 0 t 2 1 t 2 h1 (t ) ; for
q 1, 2 2
p0 1 1 0. 5 1 1 1 2 3
h1 (t ) 1; t 0 t 1 t 0, , ,
8 2 2 2 8 8 8
0 ; otherwise 1
h1 (t) ; for
2 2
4 5 6 7
t , , ,
8 8 8 8
k 2, 1 1
2 ;0t 4 h 2 ( t ) ; for
q 1, 2
p 1 1 1 1 1
h 2 (t ) 2 ; t t 0,
8 4 2 8
0 ; otherwise 1
h 2 (t ) ; for
2
2 3
t ,
8 8
h 2 ( t ) 0; for
4 5 6 7
t , , , .
8 8 8 8
k 3, 1 3 1
2 ; 2t4 h 3 ( t ) ; for
q 2, 2
p 1 1 3 4 5
h 3 (t ) 2 ; t 1 t ,
8 4 8 8
0 ; otherwise 1
h 3 (t) ; for
2
6 7
t ,
8 8
72
Unit 5 Image Transformations – Frequency Domain
h 3 ( t ) 0; for
1 2 3
t 0, , , .
8 8 8
k 4, 1 1
;0t h 4 (t) ; for
q 1, 2 8 2
p2 1 1 1 t 0
h 4 (t) 2 ; t 1
8 8 4 h 4 (t) ; for
0 ; otherwise 2
1
t
8
h 4 (t ) 0; for
2 3 4 5 6
t , , , , ,
8 8 8 8 8
7
8
k 5, 1 3 1
h 5 (t) ; for
q 2, 2; 4t8 2
p2 1 3 1 2
h 5 (t ) 2 ; t t .
8 8 2 8
0 ; otherwise 1
h 5 (t) ; for
2
3
t
8
h 5 ( t ) 0; for
1 4 5 6 7
t 0, , , , ,
8 8 8 8 8
k 6, 1 5 1
h 6 (t) ; for
q 3, 2 ;2 t 8 2
p2 1 5 3 4
h 6 (t ) 2 ; t t
8 8 4 8
0 ; otherwise 1
h 6 (t) ; for
2
5
t
8
h 6 ( t ) 0; for
1 2 3 6 7
t 0, , , , ,
8 8 8 8 8
k 7, 3 7 1
h 7 (t) ; for
q 4, 2 ;4 t 8 2
p2 1 7 6
h 7 (t ) 2 ; t 1 t
8 8 8
0 ; otherwise 1
h 7 (t) ; for
2
7
t
8
h 7 ( t ) 0; for
73
Block 2 DIGITAL IMAGE PROCESSING-II
1 2 3 4 5
t 0, , , , , .
8 8 8 8 8
The Haar transform is given in the following matrix.
1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
1 1 1 1
0 0 0 0
2 2 2 2
0 1 1 1 1
0 0 0
h k ( t ) 1 1
2 2 2 2
0 0 0 0 0 0
2 2
0 1 1
0 0 0 0 0
2 2
1 1
0 0 0 0 0 0
2 2
0 1 1
0 0 0 0 0
2 2
Fig. 7 (b) shows the output of Haar Transform of the image in Fig. 7 (a).
3.5 SUMMARY
In this unit, we discussed transformations which convert the spatial
domain image to the frequency domain. We saw that these transform
provide a variety of information based on the frequency content of the
image.We discussed in depth three very important image transforms,
namely the Discrete Fourier transformation (DFT), the Discrete Cosine
Transformation (DCT) and the Haar transform. We also discussed the
properties of each of these transforms, which shall help us in using
them for image filtering in the frequency domain.
N 1
Then, T (v, y) f ( x, y) is the same as applying the one-
y0
2
Fig. 9
i 2 ux
1 3
E2) g (u ) f ( x )e
4 x 0
4
; u 0, 1, 2, 3
1
[i i( i) 2 u ( i) 3u ]; u 0, 1, 2, 3
4
1
[i i(1) 2 u (i) u ]; u 0, 1, 2, 3
4
1
g [1 2i, i, 1 2i, i].
4
E3) Here N 4.
i 2 ux
1 3
g(u ) f (x ) e 4 ; u 0, 1, 2, 3
4 x 0
1
g (u ) [f (0) ( i) u f (1) ( i) 2 u f ( 2) (i) 3u f (3)]; u 0, 1, 2, 3.
4
1
g (0) [f (0) f (1) f (2) f (3)]
4
1
g (1) [f (0) i f (1) f ( 2) i f (3)]
4
1
g ( 2) [f (0) f (1) f (2) f (3)]
4
1
g (3) [f (0) i f (1) f ( 2) i f (3)]
4
1 1 1 1
1 i 1 i
1
Hence, the DFT matrix is A .
4 1 1 1 1
1 i 1 i
You may check if A A *T I.
76
Unit 5 Image Transformations – Frequency Domain
ux vy
1 1 1 2 i
E4) Using Eqn. (5), f ( x , y)
2 2 x 0 y 0
F( u , v ) . e 2 2
; u , v 0,1
1 1 1
4 x 0 y 0
F(u , v) (1) ux (1) vy ; u , v 0,1
1
f (0,0) (1) v F(0,1) (1) u F(1, 0) (1) u (1) v F(1,1) ; u, v 0,1
4
1 4 4 1 1
which gives f ( x, y) .
4 4 4 1 1
E5) In general, in most of the images, large part of the signal energy
lies at the low frequencies which appear in the upper left corner
of the DCT image. Since the higher frequencies present in the
lower right of the image are small enough to be neglected, the
original image can be represented in less number of coefficients,
thereby achieving compression. Therefore, as DCT has good
compaction property, it can represent the original image in less
number of coefficients and therefore, storage and transmission of
the image is better and faster. Moreover, the original image can
be recreated close to the original from the most important
components of the DCT.
1 1 1 1 1 5
1 1 1 1 2 2
1
2 2 2 0 0 3 1 2
0 0 2 2 4 1 2
1 1 2 0 5
2
1 1 1 2 0
2 1 1 0 2 1 2
1 1 0 2 1 2
1 1 2 0 1
1 1 1 1 2 1 0 2
5 2
2 1 1 2 0 2 2 3
1 1 0 2 4
77
Block 2 DIGITAL IMAGE PROCESSING-II
As can be seen, X is a linear combination of the basis vectors.
1 2 3
E8) Here N 4; n 2; p 0,1; t 0, , , . Let us write all the values
4 4 4
of Haar transform in the following table:
k , q, p h k (t ) h k ( t ) after
simplification
p 0, q 0, k 0 1 1 1
h 0 (t) for all t h 0 (t ) for
4 2 2
1 2 3
t 0, , , .
4 4 4
p 0, q 1, k 1 1 1 1
1; 0 t 2 h 1 ( t ) ; t 0,
2 4
1 1
h 1 ( t ) 1; t 1 1 2 3
2 2 h1 (t) ;t ,
2 4 4
0 ; otherwise
p 1, q 1, k 2 1 1
h 2 (t) ;t 0
2 ;0 t 4 2
1 1 1
h 2 ( t ) 2 ; t 1 1
2 4 2 h 2 (t) ;t
0 ; otherwise 2 4
2 3
h 2 ( t ) 0; t , .
4 4
p 1, q 2, k 3 1 3 1 2
h 3 (t) ;t
2; 2 t 4 2 4
1 3
h 3 ( t ) 2 ; t 1 1 3
2 4 h 3 (t) ;t
0 ; otherwise 2 4
1
h 3 ( t ) 0; t 0, .
4
Hence,
1 1 1 1
2 2 2 2
1 1 1 1
h k (t ) 2 2 2 1
1 1
0 0
2 2
1 1
0 0
2 2
78
UNIT 6
IMAGE ENHANCEMENT &
FILTERING IN FREQUENCY
DOMAIN
6.1 INTRODUCTION
In the previous units of this course, we have considered an image in the
spatial domain which is the form in which camera captures it. In this unit, we
shall view the image as a signal and apply the well known filtering techniques
used in signal processing. The only difference here will be that image would
be considered as 2-D signal (along x and y axes). We shall see that this view
of the image results in number of benefits over the spatial domain treatment.
In this unit we will also learn that the image Restoration involves
modeling of the degradations and by applying inverse process we can
recover the original image. For the restoration process, it is mandatory
that we estimate the degradation process accurately. Else we will not be
able to remove it.
Now, we shall list the objectives of this unit. After going through the unit,
please read this list again and make sure that you have achieved the
objectives.
Objectives
After studying this unit, you should be able to
define images in frequency domain
perform filtering in frequency domain
apply different types of image smoothing filters
apply different types of image sharpening filters
describe images degradation models
state difference between restoration and enhancement
apply different noise models
estimate degradation function
apply Inverse filtering
apply Wiener filtering
154
Unit 6 Image Enhancement & Filtering-Frequency Domain
Let us begin with shifting the centre of the spectrum.
1
where F(u ) R 2 ( u ) I 2 (u ) 2 (magnitude or spectrum)
I( u )
(u ) tan 1 (phase angle or phase spectrum)
R (u )
R ( u ) : the real part of F(u )
I( u ) : the imaginary part of F(u )
The various benefits of frequency domain analysis are the following:
1) It is convenient to design a filter in frequency domain. As filtering is more
intuitive in frequency domain, designing an appropriate filter is easier.
2) Implementation is very efficient with fast DFT via FFT.
3) Convolution in spatial domain reduces to multiplication in frequency
domain which is a much simpler process.
However, the image in spatial domain is not continuous but consists of
discrete values. The discrete version of fourier transform is
2 ux
1 N 1
F(u ) f ( x )e N
, u 0,1,..., N 1
N x 0
Also, since the image is two dimensional signal, we need 2D Fourier
transform. For a N N image it takes the form:
ux vy
1 N1 N1 j2
F( u , v) f ( x, y) e N
,
N x 0 y 0
where u and v are the frequencies along x and y axes and take the values
0,1, 2,..., N 1 .
In the spatial domain we consider the origin to be located at top left corner of
the image. For better display in the frequency domain, it is common to shift the
origin to centre of the image.
Periodicity of Fourier transform is given by
v ( k , l) v ( k M , l) v ( k , l N ) v ( k M , l N ) (1)
155
Unit 6 Image Enhancement & Filtering-Frequency Domain
u ( m, n ) u ( m M , n ) u ( m, n N ) u ( m M , n N ) (2)
Fig 1(a) shows that the values from N / 2 to N 1 are the same as the value
from N 1 to 0. As DFT has been formulated for value of k in the interval
[0, N 1] , the result of this formulation yield two back to back half periods in
this interval. To display one full interval between 0 to N 1 as shown in
Fig. 1(b), it is necessary to shift the origin of transform to the point k N / 2 .
To do so we have to take advantage of translation property of Fourier
transform.
M N
v(m, n ) (1) m n
FT
v k , l (3)
2 2
Fig. 1
Fig. 2 (a) and (b) show how the origin shifts from left corner of the image to
centre of the image.
Basic Property of images in Frequency Domain
1 N1 N1
v ( k , l)
N m 0 m 0
u (m, n ) WNkm WNl n 0 k, l N 1 (4)
156
Unit 6 Image Enhancement & Filtering-Frequency Domain
Also, note that the rotation of an image in spatial domain causes exactly same
rotation in frequency domain.
157
Unit 6 Image Enhancement & Filtering-Frequency Domain
Rotating f ( x , y) by rotates F( u , v) by .
Generally, the filters are centred and are symmetric about the centre. Input
image should also be centred. Following steps are followed to carry out
filtering in frequency domain (Fig. 4):
xy
Step 1: Multiply input image f ( x , y) by (1) to move the origin in the
transformed image to
M N
u and v
2 2
Step 2: Compute F( u , v) , Fourier transform of the output of step 1.
Step 3: Multiply filter function H (u , v) to F( u , v) to get G (u , v) .
Step 4: Take inverse Fourier transform of G ( u , v) to get g ( x , y) .
Step 5: Take the real part of g ( x , y) to get g r (x, y)
Step 6: Multiply the result of step 5 by (1) x y to shift the centre back to origin
and enhanced image is generated.
1. Smoothing filters
2. Sharpening filters
3. Homomorphic filters
Smoothing filters are low pass filters and are used for noise reduction. It blurs
objects. Sharpening filters are high pass filters and produce sharp images with
dark background. Laplacian and high boost filters are used to produce sharp
images. Homomorphic filters are based on illumination and reflectance model,
and create a balance between smoothing and sharpening filtering effect. This
classification is shown in Fig. 5.
158
Unit 6 Image Enhancement & Filtering-Frequency Domain
E1) Write the steps involved in frequency domain filtering with the help of
block diagram.
G ( u , v) H( u , v) F( u, v) (5)
1 D(u , v) D 0
H ( u , v)
0 D(u , v) D 0
159
Unit 6 Image Enhancement & Filtering-Frequency Domain
M
1/ 2
N
1/ 2
Fig. 6
5. Consider a circle of radius D 0 () as the cut off frequency with respect to a
threshold a such that
P(u, v) P
u v
T .
6. Thus, we can fix a threshold α which tells how much of the total energy is
retained and obtain an appropriate cut off frequency D 0 () .
Properties of ILPF
Ringing is undesirable and unpleasant lines around the objects present in the
image Fig. 7 (b). As the cut of frequency D 0 increases, effect of ringing
reduces. Ringing is a side effect of ideal lpf .
1
Radius of the centre component
cut off frequency
1
Number of circles per unit distance from origin
cut off frequency
161
Unit 6 Image Enhancement & Filtering-Frequency Domain
(a) Original image (b) Output of ILPF with D0=30 (c) Output of ILPF
with D0= 50
Fig. 7
(a) Original image (b) Output of ILPF with D0=50 (c) Output of
ILPF with D0=80
Fig. 8
1
H ( u , v) ,
1 D( u , v) / D 0
2n
M N
where the cut off frequency or distance from the centre D 0 , , and
2 2
1/ 2
2
M N
2
Fig. 9 (a) and Fig. 9 (b) show the transfer function of BLPF. Fig. 9 (c) is the
plot of BLPF and Fig. 9 (d) is BLPF displayed as an image.
The output corresponding to the change in the values of D o and n are shown
in Fig. 11.
(a) Output of BLPF for D0= 30 (b) Output of BLPF for D0= 40
where D( u , v) is the distance from the origin of Fourier transform, and is the
measure of spread/dispersion of the Gaussian curve.
Larger the value of , larger is the cut off frequency and the filter is milder.
Let D 0 then transfer function is given by
2
( u ,v ) / 2 D0 2
H ( u , v) e D ,
Fig. 12 (a) is GLPF transfer function, Fig. 12 (b) is plot of GLPF and Fig. 12 (c)
is GLPF displayed as an image. Fig. 13 (a) to Fig. 13 (c) are GLP filtered
images. No ringing is observed in the output, but only blurring is visible. As the
cut off frequency increase, blurring reduces. No ringing in the output is a very
big advantage of GLPF. These filters can be used in situations where no
artifacts are desirable (eg. medical imaging). In medical imaging, GLPF is
preferred over ILPF/ BLPF.
(a) GLPF Transfer Function for Various Values of D (b) Plot of GLPF
Fig. 12 164
Unit 6 Image Enhancement & Filtering-Frequency Domain
Fig. 13
Ideal Butter worth Gaussian
Transfer H ( u , v) H( u , v) H ( u , v) e D
2
( u ,v ) / 2 D 2
Function
1, D( u , v) D 0 1
1 D(u , v) / D 0
24
0, D( u , v) D 0
Applications Reduce noise Reduce noise Reduce noise
Problems Blurring Blurring, Ringing Blurring,
Ringing for higher order No ringing
filters ( n 2)
E3) Give the formula for transform function of a Butterworth low pass filter.
E4) Explain and compare ideal low pass filter and Butterworth filter for image
smoothing.
H h p ( u , v) l H l p ( u , v)
Here, we discuss only real and symmetric filters. Following sharpening filters
are discussed in this section:
High pass filters are used for enhancing edges. These filters are used to
extract edges and noise is enhanced, as a side effect.
166
Unit 6 Image Enhancement & Filtering-Frequency Domain
6.4.1 Ideal High Pass Filter (IHPF)
Transfer function of a 2D IHPF is given by
1, if D(u , v) D 0
H (u , v)
0, if D(u , v) D 0
Here, D 0 is the cut off frequency and D( u , v) is the distance from the origin of
the Fourier transform. Fig. 14 (a) and Fig. 14 (b) is the IHPF and its transfer
function respectively. Fig. 14 (c) is plot of IHPF and Fig. 14 (d) is IHPF as an
image. Note that the origin (0,0) is at the centre and not in the corner of the
image. The abrupt transition from 1 to 0 of the transfer function H ( u , v) cannot
be realized in practice. However, the filter can be simulated on a computer.
This filter sets to all frequencies inside the circle of radius D and passes all
frequencies above D0 without any attenuation. Ringing is clearly visible in the
output (Fig. 15 (b), and Fig. 16(c)) other than sharp edges and boundaries.
Output image looks very dark and dull as the high value DC component
G (0, 0) is eliminated.
Fig. 15 167
Unit 6 Image Enhancement & Filtering-Frequency Domain
6.4.2 Butterworth High Pass Filter (BHPF)
Butterworth filter does not have sharp transition between passband and stop
band. The slope depends on the order of the filter. Transfer function of BHPF
is
1
H (u, v) 2n
,
D0
1
D( u , v )
where n is the order of the filter, D 0 is the cut off frequency and D( u , v) is the
distance from the origin of Fourier transform.
Fig. 16 (a) and Fig. 16 (b) are BHPF transfer function and Fig. 16 (c) and
Fig. 16 (d) are plot and image display of BHPF.
Frequency response does not have a sharp transition as in the ideal HPF.
Thus, less distortion is seen in the output with no ringing effect even for
smaller values of cut off frequencies. This filter is more appropriate for image
sharpening than ideal HPF as there is no ringing in output.
Fig. 16(b) is the plot of GHPF for D 0 30, n 2, and Fig. 16 (c) GHPF
displayed as an image. Fig. 17(a) and Fig.17 (b) are the output of GHPF for D0
= 30 and 130 respectively for n 2 . It is clear from the output, as D0
increases, more and more power is removed from the output image. Thus,
output looks sharper for higher value of D 0 . Fig. 17(d) is the output for
D 0 30 n 20, ringing is clearly visible in the output. As n increases, ringing
in butterworth filter increases.
(a) Output of BHPF with D0 = 130, n = 2 (b) Output of BHPF with D0= 30, n = 2
168
Unit 6 Image Enhancement & Filtering-Frequency Domain
Fig. 17
6.4.3 Gaussian High Pass Filter (GHPF)
Gaussian high pass filters have smooth transition between passband and
stopband near cutoff frequency. The parameter D is a measure of spread of
the Gaussian curve. Larger the value D 0 , larger is the cut off frequency.
Transfer function of GHPF is
D 2 ( u , v)
H ( u , v) 1 e 2
,
2D 0
where D 0 is the cut off frequency and D( u , v) is the distance from origin of
Fourier transform.
Fig. 18(a) is GHPF Transfer function filter. Plot and image are displayed in
Fig. 18 (b) and Fig. 18 (c). Output in Fig. 19 is much smoother than previous
two filters with no ringing effect.
(a) Output of GHPF with D0=30 (b) Output of GHPF with D0=120
Fig. 19
Let us compare these three high pass filters in frequency domain filters in the
following table.
Table 1
Ideal Butterworth Gaussian
Transfer H ( u , v) H ( u , v) H ( u , v)
function
1, D ( u , v) D 0 1 D 2 (u , v)
2n 1 e
0, D ( u , v) D 0
2
D 2D 0
1
D( u , v)
Application Edge Edge enhancement Edge
enhancement enhancement
169
Unit 6 Image Enhancement & Filtering-Frequency Domain
Problems Ringing No Ringing No Ringing
Try the following exercises.
E7) How many types of high pass filters are there in frequency domain? List
them.
E8) Give the formula for transform function of a Gaussian high pass filter.
a) Noise
b) Blur
c) Artifacts
170
Unit 6 Image Enhancement & Filtering-Frequency Domain
Now, the question arises that what are the sources which contribute to
image degradation. Image degradation (as shown in Fig. 22) can
happen due to
The processes that are used to remove degradation are mainly image
enhancement and image restoration.
Enhancement Restoration
1. It gives better visual representation It remove effects of sensing
environment
2. No model required Mathematical model of
degradation
3. It is a subjective process It is an objective process
4. Contrast stretching, histogram Inverse filtering, wiener filtering,
equalization etc are some denoising are some restoration
enhancement techniques techniques.
E9) What are the factors that can cause image degradation.
f ( x, y) original image
h (x, y) degradation function
n (x, y) additive noise
g(x, y) degraded and noisy image
f̂ ( x , y) restored image
Gaussian Noise
Gaussian noise model is most frequently used in practice. The PDF of a
Gaussian random variable ‘z’ is given by
174
Unit 6 Image Enhancement & Filtering-Frequency Domain
2
( z )
1
p( z ) e 22
, (2)
2
standard deviation
Plot of p(z) with respect to z is shown in Fig. 26. 70% of its values are
in the range [( ), ( )] while 95% of the values are in the range
[( 2), ( 2)] . DFT of Gaussian (normal) noise is another
Gaussian process. This property of Gaussian noise makes it most
often used noise model. Some examples where Gaussian model is the
most appropriate model are electronic circuit noise, sensor noise due to
low illumination or high temperature, poor illumination.
Rayleigh Noise
Radar range and velocity images typically contain noise that can be
modeled by the Rayleigh distribution. Rayleigh distribution is defined by
2
2
( z a )
(z a ) e b za
p(z ) b , (3)
0 za
a b z b 1 nz
e z0
p( z ) ( b 1) ! , (4)
0 z0
b
Where a and b are positive integers, mean density is given by
a
b
and variance is 2 .
a2
Uniform Noise
Fig. 29 shows the plot of PDF of uniform noise. Uniform noise is least
used in practice.
Pa za
p(z ) , (6)
Pb zb
177
Unit 6 Image Enhancement & Filtering-Frequency Domain
Fig. 32 shows the flower image with different types of noise. It is very
easy to identify the effect of different types of noise on the images.
Fig. 32 (a) shows original image, Fig. 32 (b) shows image with
Gaussian noise. Fig. 32 (c) shows image with salt and pepper noise and
Fig. 32 (d) shows image with uniform noise. The amount of noise added
can also vary. If the amount of noise added is more, it becomes very
difficult to remove it.
178
Unit 6 Image Enhancement & Filtering-Frequency Domain
(c) Image with salt & pepper noise (d) Image with uniform noise
Fig. 32
179
Unit 6 Image Enhancement & Filtering-Frequency Domain
g(x, y) f (x, y) n( x, y)
G(u, v) F(u, v) N(u, v)
1
f̂ ( x, y) g(s, t )
mn s , tSxy
(a) (b)
(a) (b)
181
Unit 6 Image Enhancement & Filtering-Frequency Domain
Gaussian noise is added to the input image Fig. 39 (a). 3 3, 5 5 and
7 7 mean filters are applied to the noisy image and the output images
are displayed in Fig. 39 (b), (c), (d). As it is clear from the output, 3 3
filter (Fig. 39 (b)) does not remove the noise completely. Noise is still
seen in the image but blurring is less. In 5 5 (Fig. 39 (c)) filtering more
noise is removed but image gets blurred. In 7 7 (Fig. 39(d)), too much
blurring is seen in the output.
Fig. 39
Median filter replaces the pixel value by the median of the pixel values
in the neighbourhood of the centre pixel ( x, y) . The filtered image is
given by
f̂ ( x , y) median{g (s, t )}
( s , t )Sxy
182
Unit 6 Image Enhancement & Filtering-Frequency Domain
Thus, median filter provides excellent results for salt and pepper noise
with considerably less blurring than linear smoothing filter of the same
size. These filters are very effective for both bipolar and unipolar noise.
But, for higher noise strength, it affects clean pixels as well and a
noticeable edge blurring exists after median filtering.
(c) Filtered Image with Mean Filter (d) Filtered Image with Media Filter
Fig. 43
Salt and pepper noise with density of 0.3 is added to an image. The
noisy image (Fig. 44 (a)) is filtered using 3 3, 5 5 and 7 7 , median
filter. The results in Fig. 44 (b), (c), (d) show that 3 3 median filter is
unable to remove the noise completely as the noise density is high. But
5 5 and 7 7 median filters remove noise completely but some
distortions are seen specially in Fig. 44 (d).
W
1 D( u , v) D 0
2
W W
H (u , v) 0 D0 D( u , v ) D 0 , (7)
2 2
W
1 D( u , v) D o
2
where W is the width of the band (band width), D 0 is its radial centre
and D(u, v) is the distance from the origin and is given by
M
1/ 2
N
1/ 2
D(u , v) u v
2 2
D(u, v) is the distance measured from the point (u, v) to the centre
M N M N
, . If size of an image is M N, then the centre is at , .
2 2 2 2
185
Unit 6 Image Enhancement & Filtering-Frequency Domain
Transfer function of butter worth band reject filter of order ‘n’ is given by
1
H ( u , v) 2n
(8)
D( u , v) W
1 2 2
D (u , v) D 0
1 D 2 ( u , v ) D 20
2 D ( u , v ) W
H(u , v) 1 e (9)
Fig. 46 gives the plots of ideal, butterworth and gaussian band reject
filters.
H bp (u , v) 1 H br (u , v),
(10)
W
0 D(u , v) D 0 2
W W
H (u , v) 1 D 0 D( u , v) D 0 , (11)
2 2
W
0 D(u , v) D 0 2
186
Unit 6 Image Enhancement & Filtering-Frequency Domain
Where D(u, v) is the distance from origin, W is the band width
D0 is the radial centre or the cut off frequency.
2n
D( u , v) W
2
1 D (u , v) D 02
H(u , v) 1 2n
2n
(13)
D( u , v ) W D( u , v) W
1 2 2
1 2 2
D ( u , v) D 0 D ( u , v) D 0
1) Observation
2) Experimentation
3) Mathematical modelling
6.10.2 Experimentation
It is possible to estimate the degradation function accurately if the
equipment used to acquire the degraded image is available. The
processes is shown in Fig. 49.
188
Unit 6 Image Enhancement & Filtering-Frequency Domain
G ( u , v)
H( u , v ) ,
A
where G(u, v) DFT[g(x, y)] DFT [degraded impulse], and A is the
constant describing the strength of the impulse.
6.10.3 Modelling
Modelling is used to estimate the degradation function. Scientists have
studied several environmental conditions and other processes which
cause degradation, and have formulated several fundamental models
for the degradation functions. Degradation model based on atmospheric
turbulence blur is given as
2
v2 )5 / 6
H ( u , v) e k ( u
2
y2 )5 / 6
h ( x , y) e k ( x ,
189
Unit 6 Image Enhancement & Filtering-Frequency Domain
where k is a constant that depend on the nature of blur. Various values
used for the constant k along with their type of turbulence are given as
1 L L
; x 0 , y0
h ( x , y) L2 2 2 (1)
0 ; otherwise
T
H ( u , v) sin (ua vb) e j( ua vb) (2)
(ua vb)
Blur can be due to motion (camera and object moving with respect to
each other). With suitable values of T, a and b , blurred image can be
generated using this transfer function. Fig. 50(a) shows original image
and Fig. 50(b) shows blurred image.
Fig. 50
Try an exercise.
G ( u , v)
F̂(u, v) (4)
H ( u , v)
F̂(u , v) H R ( u , v) G (u , v) (6)
1
F̂(u, v) F(u, v)H(u, v) N(u, v)
H ( u , v)
F(u, v) H(u, v) N(u, v)
H ( u , v) H ( u , v)
N( u , v)
F(u, v) (7)
H ( u , v)
N( u , v)
If H(u, v) 0
H ( u , v)
1
H ( u , v)
H R ( u , v) H ( u , v)
0 H ( u , v)
where, is a small value.
As H(u, v) 0, H R (u, v) 0.
192
Unit 6 Image Enhancement & Filtering-Frequency Domain
Fig. 52
Try an exercise.
E14) Explain in brief the inverse filtering approach and its limitations in
image restoration.
where, E{.} is the expected value of the argument. Noise and image are
assumed to be uncorrelated. Filter transfer function is given by
Sfg (u, v)
H R ( u , v) , (10)
Sgg (u, v)
H * (u , v) Sff ( u , v)
H R ( u , v) 2
H (u , v) Sff ( u, v) 0
1
H R ( u , v) inverse filter
H ( u , v)
194
Unit 6 Image Enhancement & Filtering-Frequency Domain
M 1 N 1
F(u, v)
2
SNR u 0 v 0
M 1 N 1
N(u, v)
2
u 0 v 0
1 M 1 N 1
MSE [f (x, y) f̂ (x, y)]2
MN x 0 y 0
H * ( u , v) Sff (u , v)
H R ( u , v) 2
H (u , v) Sff ( u , v) S nn ( u , v)
H * (u , v)
2 S (u , v)
H ( u , v) nn difficult to estimate
S ff ( u , v)
S nn (u , v) difficult to estimate
S ff (u , v) difficult to estimate
S nn (u , v)
k (approximated by constant k)
Sff (u , v)
H * ( u , v)
H R (u , v) 2
H (u , v) k
And estimated restored image
F̂(u, v) H R (u , v) G (u , v)
H * ( u , v)
2
G (u , v)
H ( u , v) k
1 H ( u , v)
2
* G (u , v)
H ( u , v) H ( u , v ) 2 k
195
Unit 6 Image Enhancement & Filtering-Frequency Domain
k is chosen experimentally and iteratively for best results. In Fig. 53,
small noise is added to a blurred image, which is restored by wiener
filter in Fig. 53(b).If the amount of added noise is increased Fig. 53(c),
the restored image by wiener filter (Fig. 53(d)) is not good. Thus, it is
apparent that the wiener filter only works well when the noise is small.
Fig. 53
Image is blurred using linear motion = 15, angle = 5 shown in Fig. 54(b).
Wiener filter is used to deconvolve the blurred image. The output
(Fig. 54(c)) is not clear as the wiener filter does not use any prediction
about noise density.
E15) Discuss the minimum mean square error (Wiener) filtering. 196
Unit 6 Image Enhancement & Filtering-Frequency Domain
6.13 SUMMARY
In this unit, we have discussed the following points.
1. Image characteristics in frequency domain
2. Filtering in frequency domain
3. Basic steps of frequency domain filtering
4. Various low pass and high pass filters
5. Various image smoothing filters in frequency domain
6. Various image sharpening filters in frequency domain
7. Sources of degradation.
8. Difference between enhancement and restoration.
9. Image degradation/restoration model.
10. Various types of noises with their pdfs.
11. Mean and median filters for noise reduction
12. Band reject and band pass filters for periodic noise reduction.
13. Methods of estimation of degradation function.
14. Inverse filtering.
15. Wiener filtering.
M N
u and v .
2 2
1. Multiply input image f ( x , y) by (1) x y to centre the transform to
2. Compute F( u , v) , Fourier transform of the output of step 1.
3. Multiply filter function H ( u , v) to F( u , v) to get G ( u , v) .
4. Take inverse Fourier transform of G ( u , v) to get g ( x , y) .
5. Take the real part of g ( x , y) to get g r ( x , y)
6. Multiply the result of step 5 by (1) x y to shift the centre back to
origin and enhanced image is generated.
E2) Image enhancement can be done very effectively in frequency
domain. High frequency noise, undesirable breakages in the edges
and other imperfections can be taken care by filtering in frequency
domain. Low pass and high pass filters are implemented with ease
and perfection in frequency domain.
197
Unit 6 Image Enhancement & Filtering-Frequency Domain
1
E3) H ( u , v) ,
1 D( u , v) / D 0
2n
E5) Smoothing filters are low pass filters (LPF). Edges, sharp transitions
and noise in the grey levels contribute to high frequency contents in an
image. A low pass filter only passes low frequency and blocks the high
ones. It removes noise and introduces blurring as a side effect in the
image.
High pass filters are used for enhancing edges. These filters are used
to extract edges and noise is enhanced, as a side effect.
E8) Gaussian high pass filters have smooth transition between passband
and stop band near cut off frequency. The parameter D is a measure
of spread of the Gaussian curve. Larger the value D 0 , larger is the cut
off frequency. Transfer function of GHPF is
D 2 ( u , v)
H ( u , v) 1 e ,
2D 02
198
Unit 6 Image Enhancement & Filtering-Frequency Domain
where D 0 cut off frequency and D( u , v) is the distance from origin of
Fourier transform.
f ( x, y) original image
h (x, y) degradation function
n (x, y) additive noise
g(x, y) degraded and noisy image
f̂ ( x , y) restored image
Properties of Noise
199
Unit 6 Image Enhancement & Filtering-Frequency Domain
( z u ) 2
1
p( z) e 22
,
2
Rayleigh Noise
Radar range and velocity images typically contain noise that can
be modeled by the Rayleigh distribution. Rayleigh distribution is
defined by
2
2
( z a )
( z a )e b za
p(z ) b
0 za
b ( 4 )
Mean density is given a b as 2
4 4
Erlang (Gamma) Noise
b b
and variance 2 2
is
a a
200
Unit 6 Image Enhancement & Filtering-Frequency Domain
Uniform Noise
1
if a z b
p(z ) b a
0 otherwise
a b 2 (b a ) 2
,
2 12
Pa za
p( z)
Pb zb
F̂( u, v) H R (u , v) G ( u , v)
1
F̂(u, v) F(u, v) H(u, v) N(u, v)]
H ( u , v)
F(u, v) H (u, v) N (n, v)
H ( u , v) H ( u , v)
N ( u , v)
F(u, v)
H ( u , v)
1) It is an unstable filter
2) It is sensitive to noise. In practice, inverse filter is not
popularly used.
E15) This approach includes both the degradation function and power
spectrum of noise characteristics in developing the restoration
201
Unit 6 Image Enhancement & Filtering-Frequency Domain
filter. Wiener filter restores the image in the presence of blur as
well as noise.
e 2 E{(f f̂ ) 2 })
S fg (u , v)
H R (u , v)
S gg ( u , v )
F̂( u, v) H R (u , v) G ( u , v)
H * (u , v)
*
G (u , v)
H (u , v) k
1 H ( u , v)
2
* 2
G (u , v)
H (u , v) H ( u , v) k
202
Unit 6 Image Enhancement & Filtering-Frequency Domain
203
Unit 4 Colour Image Processing
UNIT 7
COLOUR IMAGE PROCESSING
7.1 INTRODUCTION
The purpose of this unit is to introduce the concepts related to colour
image processing. As we have been working with grayscale images till
now, we would like to have an in-depth discussion of how colour images
are formed and the various colour models that exist.
We shall first discuss the human vision system in Sec. 7.2. A healthy
vision system is capable of seeing the world in colour.
As you read further, we shall discuss the various colour models that
exist and the advantages and disadvantages of each in Sec. 7.3.
Now we shall list the objectives of this unit. After going through the unit,
please read this list again and make sure that you have achieved the
objectives.
73
Block 1
Objectives
After studying this unit, you should be able to:
iii) The retina is the innermost membrane of the eye. It lines the wall
of the complete posterior portion of the eye. The retina can be
thought of as the image plane in the eye, since on properly
focussing the eye on an object, light from that object is passed
through the lens such that the image is formed on the retina.
The retina consists of two types of cells called rods and cones.
The cones are highly sensitive to colour and are around 6-7
million in a human eye. The cones are located on the focea
which is the central portion of the retina.
However, there are 75-150 million rod cells which are completely
distributed all over the retina. The rod cells give the overall
picture of the object in the scene, and reduce the amount of
detail. Rods are also responsible for low light vision, also known
as SCOTOPIC vision, while cones are responsible for bright
light vision, also known as PHOTOPIC vision.
In the human eye, the distance between the retina and lens, that
is the focal length, varies between 14 and 17 mm as the
refractive power of the lens increases from min to max. For a
nearby object, the lens is most strongly refractive. Moreover, the
lens of the eye is very flexible and is flattened by controlling
muscles to enable the eye to focus on distant objects.
So, by now you know the fundamental concepts about human vision
system. In the following section, we are going to highlight various colour
models. You must have heard about some of them in your day-to-day
life.
Fig. 2: Part of the electromagnetic spectrum that shows the visible spectrum
Source:
76
Unit 4 Colour Image Processing
ii) Saturation: The excitation purity of the colour is determined by the
quantity known as saturation.It is dependent on the amount of
white light that is mixed with hue of that colour. A fully saturated
colour implies that no white light is mixed with that hue.
iii) Chromaticity: The sum of hue and saturation constitutes the
chromaticity of the colour. Therefore, if there is no colour, it is called
achromatic light.
iv) Intensity: The amount of light actually present defines the intensity.
Therefore, intensity is a physical quantity. If more light is present,
the colour is more intense. Achromatic light has only intensity but no
colour. Grayscale images have only intensity
v) Luminance or Brightness: The perception of colour is the quantity
known as luminance or brightness. For example, given two colours
of the same intensity, such as blue and green, it is perceived that
blue is much darker than green.
vi) Reflectance: The ability of an object to reflect light, is the
reflectance property of the object. The reflectance property
determines the colour of the object, since, we see those colours that
are reflected back and not the ones that are absorbed. For example,
an object that reflects green, absorbs all other colours in the white
light spectrum except green.
There are about 6 to 7 million cones in the human eye and they are
responsible for recognising colours. Nearly, 65% of the cones recognise
red, 33% are sensitive to green and about 2% to blue. Red, green and
blue are known as the primary colours and nearly all other colours are
seen as a combination of these primary colours. However, there is a
difference between the primary colours of light and the primary colours
of pigments. The primary colours of light are red, blue and green and
they can be added to produce the secondary colours of light that are
yellow(red plus green), magenta (red+blue) and cyan (green + blue).
Moreover, the primary colours of pigments are said to be those that
absorbs a primary colour of light and reflects the other two. Therefore,
in tHSI case, the primary colours are cyan, magenta and yellow while
the secondary colours are red, blue and green.
X Y Z
x ,Y and z ... (1)
XYZ XYZ XYZ
It is obvious that
x y z 1. ... (2) 77
Block 1
Thus a 2-D diagram is adequate to show the coordinates x and y.
z 1 ( x y) ... (3)
Example 1: Consider the coordinates of warm white (0.45, 0.4) and the
coordinates of deep blue (0.15, 0.2). Find the percentage of the
three colours red (X), green (Y) and blue ( Z).
z 1 ( x y)
1 (0.45 0.4)
0.15
X
0.45
XYZ
Y
0.4
XYZ
Z
0.15
XYZ
Solution: Let the colour C lies on the line have the coordinate ( x, y).
Now the question arises how do we find the composite colour in RGB
colour model at any point. For this we follow the following steps:
Step 1: Pixel depth is the number of bits used to represent each pixel. If
an image in RGB model has 8-bit image in each of its three colours,
then each RGB pixel has a depth of 3 image planes 8-bit per plane
that is 24 bits. This gives rise to 2 24 colour shades.
Step 2: We fix one of the three colours and let the other two colours to
vary. Suppose we fix R 127 and let G and B to vary. Then the colour at
any point on the plane parallel to GB plane would be (127, G, B), where,
G, B 0, 1, ...., 255.
R B 1 G
G (R G B)
2 2 2 2
1
mid grey G.
2
Pure green with some grey component.
***
Now, try an exercise.
E3) How many different shades of grey are there in a colour RGB
system if each RGB image is an 8 bit image?
Cyan (C), Magenta (M) and Yellow (Y) are the primary colours of
pigments and the secondary colours of light. The CMY model is a
subtractive model, implying that it subtracts a colour from the white light
and reflects the rest. For example, when white light is reflected on cyan,
it subtracts Red and reflects the rest. While RGB is an additive model,
where something is added to black (0,0,0) to get the desired colour
CMY is a subtractive model. The conversion between CMY and RGB
model is given by the Equation below.
C 1 R
M 1 G ... (4)
Y 1 B
81
Block 1
where, the RGB values have been normalised. THSI also gives a
method to convert from RGB to CMY to enable printing hardcopy, since
the CMY model is used by printers and plotters.
(a) (b)
Fig. 4(a) shows the RGB model, in which the white colour is produced
by adding the three primary colours Red, Green and Blue. Fig. 4 (b)
shows the CMY model, where black is obtained as the sum of Cyan,
Magenta and Yellow. The inverse relation between the RGB and CMY
models are also shown by these two images.
Now check by doing the following exercise, what have you understood.
E4) Why do we get green coloured paint on mixing blue and yellow
coloured paints?
This colour model is very close to human colour perception which uses
the hue, saturation and intensity components of a colour, when we see
a colour, we cannot describe it in terms of the amount of cyan, magenta
and yellow that the colour contains. Therefore, the HSI colour model
was introduced to enable describing a colour by its hue, saturation and
intensity/ brightness. Hue describes the pure colour, saturation
describes the degree of purity of that colour while intensity describes
the brightness or colour, sensation. In a grayscale image, intensity
defines the graylevel. Fig. 6 shows the HSI colour model and the way
colours may be specified by this colour model.
82
Unit 4 Colour Image Processing
(a) (b)
Fig. 5: (a) HSI and (b) RGB
In Fig.5, the HSI colour model is represented and its relation to RGB
model is shown in the Fig. 5 (b). The HSI triangle in Fig. 5 (b) shows a
slice from the HSI solid at a particular intensity as shown in Fig. 5 (a).
You may notice that in Fig. 5, the hue, saturation and intensity values
required to form the HSI colour space can be computed using the RGB
values.
E6) Write the full form of HSI and define each of the components.
To convert an image in RGB format to HSI colour space, the RGB value
of each pixel in the image, is converted to the corresponding HSI value
in the following manner. Hue, H is given by
if B G
H ... (5)
360 if B G
where,
1
[(R G ) (R B)]
cos 1 2
1/ 2
[(R G ) (R B)(G B)]
2
Saturation, S is given by
3
S 1 [min (R , G, B)]
(R G B) 83
Block 1
And, intensity, I is given by
1
I (R G B)
3
Where, the RGB values have been normalised in the range [0,1] and
the angle is measured with respect to the red axis in the HSI space.
Given pixel values in the HSI colour space in the interval [0,1] , the RGB
values can be computed in the same range. However, depending on the
H value, the RGB values are computed in different sectors, based on
the separation of the RGB colours by 120° intervals.
First, multiply the H value by 360°, to get the hue value in the interval
[0°, 360°].
S cos H
R 11 ... (9)
cos(60 H )
o
G 31 (R B) ... (10)
In the GB Sector, 120o H 240o then in this case, we first convert the
value of H as
S cos H
G I 1 ... (12)
cos(60 H )
o
B 31 (R B) ... (13)
S cos H
B I 1 ... (15)
cos(60 H)
o
84
Unit 4 Colour Image Processing
R 3I (R B) ... (16)
Fig. 6
Solution: It is given here that the intensity and saturation are maximum,
therefore the value of each of the components RGB would be 0 or 1.
Let us check each colour of the image one by one by starting from the
left most colour.
Colour RGB Intensity/Saturation Monochrome
combination colours
R G B R G B
White R+G+B 1 1 1 255 255 255
Magenta R+B 1 0 1 255 0 255
Blue B 0 0 1 0 0 255
Cyan G+B 0 1 1 0 255 255
Green G 0 1 0 0 255 0
Yellow R+G 1 1 0 255 255 0
Red R 1 0 0 255 0 0
Black NIL 0 0 0 0 0 0
Now hence forth we shall follow the conversion that 0 represents black
and 255 represents white. Also, the grey is represented by 128. You
see that the table has R colour series as 255, 255, 0, 0, 255, 255, 0.
Thus, it would show W, W, B, B, B, W, W, B in monochrome display,
which is shown in Fig. 7 (a).
Similarly monochrome display of green colour would be shown by the
series W,B,B,W,W,W,B,B and blue would be shown as W, W, W, W, B,
B, B, B, B as shown in Fig. 7 (b) and Fig. 7 (c).
(a) (b) 85
Block 1
(c)
Fig. 7
***
Example 5: Let us sketch the HSI components of the image considered
in Fig. 6 [Given in Example 4] on a monochrome display.
Solution: We tr
transform
ansform HSI by computing values of H, S and I for each
colour.
For white R 1, G 1, B 1
Using Eqn. (5), we can say that H does not exist as denominator is zero
while computing .
1
Using Eqn. (7), we get I (1 1 1) 1 and using Eqn. (6), we get
3
3
S 1 [min(1,1,1)] 0.
111
Similarly we can find H, S, I for each of the colours as shown in the
following table.
Colour R G B H S I Monochromatic
H S I
White 1 1 1 Cannot 0 1 ̶ 0 255
be
computed
Magenta 1 0 1 5 1 2 213 255 170
6 3
Blue 0 0 1 2 1 1 170 255 85
3 3
Cyan 0 1 1 1 1 2 128 255 170
2 3
Green 0 1 0 1 1 1 85 255 85
3 3
Yellow 1 1 0 1 1 2 43 255 170
6 3
Red 1 0 0 0 1 1 0 255 85
3
Black 0 0 0 ̶ 0 0 ̶ ̶ 0
86
Unit 4 Colour Image Processing
(a) (b)
(c)
Fig. 8
The output is given in Fig. 8 (a), Fig. 8 (b) and Fig. 8 (c) for each of the
attribute H,S and I.
***
Now try the following exercises.
E8) Describe how the grey levels vary in RGB primary images that
make up the font face of the colour cube.
E9) Transform the RGB cube by its CMY cube. Lable all the vertices.
Also, interpret the colours at the edges with respect to saturation.
87
Block 1
whose graylevel is below the plane can be coded in another colour,
thereby converting the grayscale image into a two colour image.
7.6 SUMMARY
In this unit, we discussed the following points:
1. The need for colour image processing. Since the human eye has the
wonderful capability of seeing millions of colour, we realise that
colour gives a large amount of information about the objects and
scene in the images.
2. We first discussed the structure of the human eye and then the
tristimulus theory that connects the perception of colour with the
various colour models that exist.
3. We then discussed the main colour models or colour spaces that are
mainly used in both TV and print.
7.7 SOLUTIONS/ANSWERS
E1) Since when object is far, the focal length is 17 mm for the human
eye, therefore, 15 / 100 h / 17 h (17 *15) / 100 2.55 m
88
Unit 4 Colour Image Processing
E2) THSI problem is the extention of the problem solved in Example 2.
Here, we consider two possibilities.
i) When the point C at which percentage of colours C1 , C 2 and
C 3 to be found is on the sides of triangle. In this case the
percentage is found by considering the point on the line
joining the corresponding vertices as we solved in Example
2. There would be 0% from the vertex which does not lie on
the line. For example, if the point lies on the line joining C1
and C 2 , then the percentage of C1 and C 2 can be found as
given below.
Let the coordinates of C1 be ( x 1 , y1 ), C 2 be ( x 2 , y 2 ), C 3 be
( x 3 , y 3 ) and C be ( x, y).
Percentage of C1 in
( x x 1 ) 2 ( y y1 ) 2 ( x 2 x ) 2 ( y 2 y) 2
C 100
( x 2 x 1 ) 2 ( y 2 y1 ) 2
Percentage of C 2 in C (100 percentage of C1 ) %
Percentage of C 3 in C 0 % .
ii) When the point C does not lie on the sides of the triangle
with vertices C1 , C 2 and C3 .
In HSI case we join the point C with any of the vertices say
C 3 . We follow the following steps.
iii) Join the points C and C 3 and extend the line towards the
side C1C 2 . Suppose it intersects C1C 2 at C 4 .
iv) Find the percentage of C1 and C 2 at C 4 .
v) Use the concept that the ratio of C1 and C 2 will remain same
at each of the points on the line C 3C 4 .
vi) Now, we can easily find the coordinates of the point C 4 by
writing equation of the lines C1C 2 and C 3C. C 4 is the point of
intersection of C1C 2 and C 3 C.
vii) Finally, we can find the percentage of C 4 and C 3 for the
colour C.
E3) For an 8-bit image, there are 28 256 possible values. A colour
will be grey if each of the colour in RGB is same. Therefore, there
can be 256 shades of grey.
E4) You can see in Fig. 5, yellow paint is made by combining green
and red while imperfections in blue leads to reflection of some
amount of green from blue paint also. Therefore, when both blue
and yellow are mixed, both reflect the green colour, while all
other colours are absorbed. Therefore, green coloured paint
results from mixing of blue and yellow paints.
E5) H stands for Hue, which represents dominant colour as observed
by an observer and the corresponding wavelength is also
dominant. S stands for Saturation, which is the amount of white
89
Block 1
light mixed with a hue. I stands for intensity which reflects the
brightness.
E7) A colour space allows one to represent all the colour perceived
by human eye. The colour space can be broadly classified into (i)
RGB, (ii) GMY and (iii) HSI colour space.
E8) Each of the components in RGB model would vary from 0 to 255.
Here, we are discussing the front face. So, we fix all pixel values
in the Red image as 255 and let the columns to vary from 0 to
255 in the green image and rows to vary from 255 to 0 in the blue
image.
E9) The vertices would be as given below:
White (0, 0, 0)
Cyan (1, 0, 0)
Magenta (0,1, 0)
Blue (1,1, 0)
Green (1, 0,1)
Red (0,1,1)
Black (1,1,1) .
The edges which are free from black or white pixels are fully
saturated. The saturation decreases towards the ends having
black or white pixel.
References
[1] R.C. Gonzoles and R.E. Woods, Digital Image Processing, Addision-
wesley, 1992.
90