Digital Signal and Image Processing
Digital Signal and Image Processing
Processing
(CSC701)
ge
io led
ic ow
Dhananjay K. Theckedath
M. Tech. - IIT (Mumbai) - Biomedical Engineering,
B.Sc. Tech. - Electronic Instrumentation
B.Sc. - Physics,
Assistant Professor,
Thadomal Shahani Engineering College,
Mumbai University, Maharashtra, India.
Copyright © by Author. All rights reserved. No part of this publication may be reproduced, copied, or stored in a retrieval
system, distributed or transmitted in any form or by any means, including photocopy, recording, or other electronic or
mechanical methods, without the prior written permission of the publisher.
This book is sold subject to the condition that it shall not, by the way of trade or otherwise, be lent, resold, hired out, or
otherwise circulated without the publisher’s prior written consent in any form of binding or cover other than which it is
published and without a similar condition including this condition being imposed on the subsequent purchaser and without
ge
limiting the rights under copyright reserved above.
io led
First Printed in India : August 2008 (For UPTU)
First Edition : July 2019(TechKnowledge Publications)
ic ow
This edition is for sale in India, Bangladesh, Bhutan, Maldives, Nepal, Pakistan, Sri Lanka and designated countries in
n
South-East Asia. Sale and purchase of this book outside of these countries is unauthorized by the publisher.
bl kn
at
Pu ch
P
Te
ISBN : 978-93-89424-30-0
Published by
TechKnowledge Publications
ge
io led
ic ow
n
bl kn
at
Pu ch
Te
Dear Students,
I am extremely happy to present this book “Digital Signal & Image Processing” for you. I have
divided the subject into small chapters so that the topics can be arranged and understood properly. The
topics within the chapters have been arranged in a proper sequence to ensure smooth flow and
ge
understanding of the subject.
io led
A number of solved examples have been included. So, I am sure that this book will cater all
I am thankful to Prof. Arunoday Kumar, Shri. Shital Bhandari & Shri. Chandroday Kumar for the
encouragement and support that they have extended. I am also thankful to the staff members of
TechKnowledge Publications and others for their efforts to make this book as good as it is. I have made
every possible efforts to eliminate all the errors in this book. However if you find any, please let me
know, because that will help me to improve the book quality further.
I am also thankful to my family members and friends for their patience and encouragement.
- Author
Course Objectives :
1. To understand the fundamental concepts of digital signal processing and Image processing.
2. To explore DFT for 1-D and 2-D signal and FFT for 1-Dsignal
3. To apply processing techniques on 1-D and Image signals.
ge
4. To apply digital image processing techniques for edge detection.
Course outcomes :
io led
On successful completion of the course learner will be able to :
1. Apply the concept of DT Signal and DT Systems.
ic ow
5. Differentiate between the advantages and disadvantages of different edge detection techniques
Pu ch
Module Unit
Topic details Hrs.
No. No.
1.0 Linear Convolution formulation for 1-D and 2-D signal (without mathematical proof), 14
Circular Convolution (without mathematical proof), Linear convolution using Circular
Convolution. Auto and Cross Correlation formula evaluation, LTI system, Concept of Impulse
1.3 Response and Step Response, Output of DT system using Time Domain Linear Convolution.
2.1 Introduction to DTFT, DFT, Relation between DFT and DTFT, IDFT
Properties of DFT without mathematical proof (Scaling and Linearity, Periodicity, Time Shift
2.2 and Frequency Shift, Time Reversal, Convolution Property and Parsevals‘ Energy Theorem).
2.0 08
DFT computation using DFT properties.
Transfer function of DT System in frequency domain using DFT. Linear and Circular
2.3 Convolution using DFT, Convolution of long sequences, Introduction to 2-D DFT
(Refer Chapter 3)
ge
3.2 DIT-FFT Flow graph for N=4 and 8, Inverse FFT algorithm.
4.1 Introduction to Digital Image, Digital Image Processing System, Sampling and Quantization
4.0 08
ic ow
Neighborhood Processing, Spatial Filtering, Smoothing and Sharpening Filters, Median Filter.
5.3
(Refer Chapters 7 and 8)
Image Segmentation
Total 52
1.1.1 Digital Signal Processing System ................................ 1-2 2.3.2 Time Reversal ........................................................... 2-12
1.1.2 Advantages of Digital signal Processing 2.3.3 Time Scaling ............................................................. 2-12
over Analog Signal Processing .................................... 1-3
ge
2.3.4 Scalar Multiplication .................................................. 2-13
1.1.3 Difference between DSP and ASP .............................. 1-3 2.3.5 Signal Addition and Multiplication .............................. 2-14
1.1.4 Limitations of Digital signal Processing ....................... 1-4 2.3.6 Solved Examples on Signals ..................................... 2-14
io led
1.2 Signals ........................................................................ 1-4 2.4 Discrete Time Systems ............................................. 2-17
1.2.1 Continuous and Discrete Time Signals ........................ 1-4 2.4.1 Representation of a Signal in Terms of
ic ow
1.2.2 Continuous Valued and Discrete Weighted Sum of Shifted Discrete Impulse ............... 2-20
Valued Signals ............................................................ 1-6
2.5 Impulse Response and Convolution .......................... 2-21
n
1.2.3 Deterministic and Random Signals .............................. 1-6
bl kn
1.3.2 Concept of Frequency in Discrete 2.5.3(A) Solved Examples on Tabular Method ........................ 2-27
1.5.1 Solved Examples ....................................................... 1-14 Introduction to DTFT, DFT, Relation between DFT and
1.6 Applications of DSP................................................... 1-17 DTFT, IDFT, Properties of DFT without mathematical
Chapter 2 : Discrete Time Signal and System proof (Scaling and Linearity, Periodicity, Time Shift and
Frequency Shift, Time, Reversal, Convolution Property
2-1 to 2-29
and Parsevals‘ Energy Theorem). DFT computation using
Syllabus : DFT properties. Transfer function of DT System in
Classification of Discrete-Time Signals, Classification of frequency domain using DFT. Linear and Circular
Discrete- Systems Linear Convolution formulation for 1-D Convolution using DFT, Convolution of long sequences,
and 2-D signal (without mathematical proof), Auto and Introduction to 2-D DFT Circular Convolution (without
Cross Correlation formula evaluation, LTI system,
mathematical proof), Linear convolution using Circular
Concept of Impulse Response and Step Response,
Output of DT system using Time Domain Linear Convolution. Spectral Analysis using FFT
Convolution 3.1 The Fourier Transform................................................. 3-1
DSIP (MU-Sem.7-COMP) 2 Table of Contents
3.2 Discrete Time Fourier Transform ................................. 3-2 4.1 Introduction ................................................................. 4-1
3.2.1 Solved Examples on DTFT of Standard Signals .......... 3-2 4.2 Computational Complexity of DFT ............................... 4-1
3.3 Relationship between DTFT and DFT.......................... 3-4 4.3 Decimation In Time FFT (DIT-FFT) ............................. 4-2
3.4 Discrete Fourier Transform (DFT)................................ 3-4 4.4 Bit Reversal Format..................................................... 4-6
3.4.1 Solved Examples on DFT of Simple Signals................ 3-5 4.4.1 Solved Examples on Bit Reversal Format ................... 4-6
3.5 The Fourier Spectrum................................................ 3-13 4.5 Decimation in Frequency FFT (DIT-FFT) ................. 4-17
3.6 Inverse Discrete Fourier Transform (IDFT) ................ 3-14 4.5.1 Solved Examples on DIT-FFT ................................... 4-20
3.7 Computing DFT by Matrix Method ............................. 3-15 4.6 Computational Complexity Comparison
between DFT and FFT .............................................. 4-30
3.7.1 Solved Examples of DFT ........................................... 3-16
4.6.1 Solved Examples on Computation of Inverse
3.8 Discrete Fourier Transform (DFT) Properties ............ 3-29
DFT using FFT Algorithms ........................................ 4-31
3.8.1 Linearity..................................................................... 3-29
4.6.2 Filtering using FFT Algorithms ................................... 4-37
ge
3.8.2 Periodicity.................................................................. 3-30
3.8.3 Circular Time Shift ..................................................... 3-31 Chapter 5 : Introduction to Image Processing
3.10.1 Overlap - Save Method .............................................. 3-60 Chapter 6 : Sampling and Quantization 6-1 to 6-10
3.10.2 Overlap - Add Method ............................................... 3-62
3.10.3 Solved Examples on Method ..................................... 3-64
Syllabus :
Sampling and Quantization. Representation of Digital
3.11 Summary of DFT properties ...................................... 3-66
Image
3.12 2 D- Discrete Fourier Transform (2-DFT) .................. 3-66
6.1 Introduction ................................................................. 6-1
3.12.1 The Separability Property ......................................... 3-66
6.2 Sampling ..................................................................... 6-1
3.12.2 Solved Examples on 2- DFT ...................................... 3-67
6.3 Quantization ................................................................ 6-5
Chapter 4 : Fast Fourier Transform 4-1 to 4-41
6.4 Isopreference Curves .................................................. 6-8
Need of FFT, Radix-2 DIT-FFT algorithm, DIT-FFT Flow 6.6 Physical Resolution ..................................................... 6-9
graph for N=4 and 8, Inverse FFT algorithm. 6.6.1 Solved Examples on Physical Resolution .................... 6-9
DSIP (MU-Sem.7-COMP) 3 Table of Contents
ge
9.2 Image Segmentation based on Discontinuities ............ 9-2
7.4.2 Noise ......................................................................... 7-10
9.2.1 Point Detection ............................................................ 9-2
7.4.3 Low Pass Averaging Filter ......................................... 7-11
io led 9.2.2 Line Detection ............................................................. 9-2
7.4.4 Low Pass Median Filtering......................................... 7-14
9.2.3 Edge Detection ............................................................ 9-3
7.5 Highpass Filtering...................................................... 7-16
9.3 Detection of Edges ...................................................... 9-5
ic ow
Introduction to Digital
1 Signal Processing
Syllabus :
Introduction to Digital Signal Processing, Sampling and Reconstruction, Standard DT Signals, Concept of Digital
Frequency, Representation of DT signal using Standard DT Signals, Signal Manipulations(shifting, reversal, scaling,
addition, multiplication).
1.1 Introduction
ge
A signal is defined as any physical quantity that varies
with time, space or any other independent variable.
io led
Anything that carries some information can be called a
signal.
Examples of signals that we encounter frequently in
ic ow
ge
io led
ic ow
Associated with all the above mentioned signals are c) Signal processing : Production of a desired output
n
the means by which these signals are generated. signal from an input signal is known as signal
bl kn
and depolarization of the ventricles of the heat. and signal processing methods.
Hence signals can be said to be generated by a system.
1.1.1 Digital Signal Processing System
Te
Fig. 1.1.4
Digital signal processing, which this chapter is all about, provides an alternate method of processing the same signal.
In this method we convert the continuous signal to a discrete time signal, also known as a digital signal, using an
Analog to Digital Converter (ADC).
The output of the ADC is fed to a digital processor (could also be a computer) which processes the discrete time signal.
The output of the digital processor is again in digital form. This needs to be converted back to the continuous signal
for any output device to understand it. This is done by using a Digital to Analog Converter (DAC). Let us take the same
example of trying to amplify a voice signal. If we do it using a digital signal processor, we would have the following
block diagram as shown in Fig. 1.1.5.
ge
io led
Fig. 1.1.5
In general we have,
ic ow
n
bl kn
Fig. 1.1.6
Here, x(t) Continuous time input signal. x(n) Discrete time input signal.
at
Pu ch
y(n) Discrete time output signal. y(t) Continuous time output signal.
5. Complex mathematical algorithms can be easily
1.1.2 Advantages of Digital Signal
Te
ge
In spite of the obvious advantages of DSP systems over (a) (b)
the ASP systems, it would be unfair if we do not highlight
Fig. 1.2.1
io led
the disadvantages of the DSP systems.
These signals can be represented as,
1. A DSP system makes use of an ADC’s and DAC’s. These
devices slow down the process. Hence a DSP system is a) x(t) = A sin (t + )
ic ow
–t/RC
not as fast as an ASP system. b) x(t) = e
2. A typical DSP chip contains thousands of transistors As can be seen in Fig.1.2.1, continuous time signals are
n
and hence the power consumption is more compared defined for every instance of time.
bl kn
they are not suitable for signals which have a huge A discrete time signal is one that is defined only at
bandwidth. The ADC needs to sample the input signals specific values of time. Two discrete time signals are
Te
at twice the bandwidth of the input signal to avoid shown in Fig. 1.2.2.
aliasing. If the frequency content in the input signal is
very larger, the ADC will need to sample it at least
twice that frequency. There is a practical limitation on
the speed of the ADC. Hence it is advisable to use ASP
systems when the bandwidth of the input signal is very
large.
With this background, we now move to discuss signals
and systems.
We shall first study the various types of signals and
(a)
then study the different systems.
1.2 Signals
(b)
Fig. 1.2.2
DSIP (MU-Sem. 7-COMP) 1-5 Introduction to Digital Signal Processing
We do not know what is the value between 0 and 1 or between 1 and 2. Hence a discrete time signal exists only at
specific values of time.
A discrete time signal is obtained from a continuous time signal using the sampling operation.
ge
io led
ic ow
n
bl kn
Fig. 1.2.3 : Sampling of a Continuous time signal to obtain a Discrete time signal
Hence a discrete time signal is an approximation of the continuous time signal. To get a good approximation we need
at
Pu ch
to take more samples in an interval i.e., reduce the sampling period (Ts) (increase sampling frequency). A typical
discrete time signal can be represented by the equation.
Te
x(n) = A cos n
Fig. 1.2.4
DSIP (MU-Sem. 7-COMP) 1-6 Introduction to Digital Signal Processing
ge
io led
ic ow
n
Fig. 1.2.5 : Discrete valued signal which is also discrete in nature
bl kn
ge
This relation will be true only if
2fN = 2k
io led
k
f =
N
k
ic ow
rational number.
Pu ch
Time Signals Hence x2(n) looks identical to x1 (n) even though x1(n)
has a frequency 0 and x2 (n) has a frequency (0+ 2).
A discrete time domain signal in represented as,
This can be generalized to state that all time signals
`x (n) = A cos (2fn + ) – n + …( 1.3.2)
xk(n) = A cos (k n + ) k = 0, 1, 2, 3
One such discrete time signal is shown in Fig. 1.3.3. where, k = 0 + 2k – 0 +
are identical
Therefore while all x(t)’s were distinct, their discrete time
domain counterparts, x(n)’s are not
DSIP (MU-Sem. 7-COMP) 1-8 Introduction to Digital Signal Processing
ge
1 1
– f+ Analog to Digital Converter (ADC).
2 2
Fig. 1.3.4
discrete time domain counterparts, x(n)’s, have a
n
1 1 The sampling process can be visualized as a simple
range of f +
2 2
bl kn
Fig. 1.3.5
Since the switch closes every T seconds, we get the output only at fixed intervals of time.
1
The sampling rate Fs = T
s
From Fig. 1.3.5, it is clear that the x-axis which represents time gets replaced by nTs in the discrete domain.
t = nTs in the discrete domain
We can have thus convert an analog signal to a discrete time signal by replacing t=nT, where T is the Sampling period.
DSIP (MU-Sem. 7-COMP) 1-9 Introduction to Digital Signal Processing
Fig.1.3.6
Hence we obtain a digital signal that is represented as, Only if Fs 2F, will f remain in the distinct
x(nT) = x(n) = A cos (2 F n Ts + ) …(1.3.4) 1 1
range of – 2 f + 2
1
We know that Ts is the sampling period i.e, Ts = F , This is known as the Nyquist criteria.
s
where, Fs is the sampling frequency. If Fs 2F, f will no longer remain in the distinct range
1 and will give rise to aliasing.
Substituting Ts = F in Equation (1.3.4) we get,
s 1 1
Therefore a range of – 2 f + 2 implies that Fs 2F
x(n) = A cos 2 n +
ge
F
…(1.3.5)
Fs
Hence, an Analog signal x(t) = A cos (2F t + ) can be
io led 1.4 Aliasing and Nyquist Rate
n
converted to a digital signal by replacing t = nT= F . Aliasing is a phenomenon where high frequencies look
s
identical to low frequencies because of low sampling
F frequency.
ic ow
Let f =
Fs
In order to represent a continuous signal faithfully, we
Substituting this value of f in Equation (1.3.5), we get need to take as many samples as possible. This is done
n
the standard representation of a discrete time signal. by an Analog to Digital Converter having a high
bl kn
where, f =
Pu ch
Fs
Sampling theorem was introduced in 1949 by Shannon
1 1 and is also called as Shannon sampling’s theorem.
We know that the range of f is – 2 f 2
Te
Here F is the frequency of input signal (in Hz) while Fs x2 (t) = 5 cos 2 (10) t
is the sampling frequency (in Hz). x3 (t) = 5 cos 2 (15) t
Soln. : 9
Since 8 > 1, it can be written as,
We will first solve this example mechanically and then
x4 (n) = 5 cos 21 +
analyze the results obtained. 1 ∵ 9 = 1 + 1
n
8 8 8
The given signals have the following frequencies.
x4 (n) = 5 cos 2 + 2 n
1
x1 (t) = 5 Hz, x2 (t) = 10 Hz, x3 (t) = 15 Hz, x4 (t) = 45 Hz, 8
x5 (t) = 50 Hz and x6 (t) = 130 Hz, Since cos (2 + ) = cos we write,
ge
x5 (n) = 5 cos 2
5
x(n) = A (cos 2 fn + ) …(2)
4 n
F
Here = f
Fs
io led 5
Since > 1, it can be written as,
4
In our case Fs = 40 Hz
x5 (n) = 5 cos 21 +
1 ∵ 5 = 1 + 1
We will convert each of the given continuous signals into n
4 4 4
ic ow
40 Since cos (2 + ) = cos we write,
8 4 n
Pu ch
f1 = = 0.125 …(3)
8
x6 (t) x6 (t) = 5 cos 2130t
x2 (t) x2 (t) = 5 cos 210t
x6 (n) = 5 cos 2
130 13
x2 (n) = 5 cos 2 n
10
40 40 n = 5 cos 2 4 n
13
x2 (n) = 5 cos 2 n
1
Since > 1, it can be written as,
4 4
= 5 cos 23 +
1 1 ∵ 5 = 3 + 1
f2 = = 0.25 …(4) n
4 4 4 4
x3 (t) x3 (t) = 5 cos 215t
x6 (n) = 5 cos 6 + 2
1
n
4
x3 (n) = 5 cos 2 n
15
40
Since cos (6 + ) = cos we write,
x3 (n) = 5 cos 2 n
3
8 x6 (n) = 5 cos 2
1
3 4 n
f3 = = 0.325 …(5)
8 1
f6 = = 0. 25 …(8)
x4 (t) x4 (t) = 5 cos 245t 4
Sr. Continuous time Value of Is the Nyquist Discrete time signal Value of Is f distinct
No. signal analog condition satisfied ? Discrete
frequency Fs 2F frequency(f)
(Fs = 40 Hz)
ge
x5 (n) = 5 cos 24 n
5. x5 (t) = 5 cos 2 50t F5 = 50 Hz No 1 1 No (f5 same as f2)
f5 = 4 = 0.25
We observe that, x4 (n) looks identical to x1 (n). sampled all the signals at a sampling frequency of
Similarly x5 (n) and x6 (n) are identical to x2 (n). This is Fs 2 130 Hz
n
known as Aliasing. It is important to note that the Fs 260 Hz
bl kn
end
subplot(6,1,1)
stem(x1)
ylabel(‘x1(n)’)
subplot (6,1,2)
stem(x2)
ylabel (‘x2(n)’)
subplot(6,1,3)
stem(x3)
ylabel(‘x3(n)’)
ge
subplot(6,1,4)
Fig. P.1.4.1(a)
stem(x4)
Ex.1.4.2 : Consider the analog sinusoidal signal
io led
ylabel(‘x4(n)’)
x (t) = 5 sin (500 t)
subplot(6,1,5)
If the signal is sampled at Fs = 1500 Hz,
ic ow
stem(x5) (i) What is the discrete time signal obtained after sampling.
ylabel(‘x5(n)’) (ii) Find the frequency of discrete time signal.
n
subplot(6,1,6) (iii) If sampling frequency Fs = 300 Hz then obtain discrete
bl kn
time signal.
stem(x6)
at
Soln. :
Pu ch
ylael(‘x6(n)’)
Given : x (t) = 5 sin (500 t)
(i) Fs = 1500 Hz
Te
Now
5
= 2 – frequencies have very small amplitudes, but they exist).
3 3 Nyquist criteria of Fs 2 Fmax will never be satisfied in
x(n) = 5 sin 2 – n such cases and we will always encounter aliasing. These
3
Band unlimited signals are converted to Band limited
x(n) = 5 sin – n signals by passing them through a low pass filter. The sole
3
ge
purpose of this low pass filter is to remove very high
x(n) = – 5sin frequencies thereby making the signal band limited and
io led3 n hence removing the affects of aliasing. These low pass
This is the discrete time signal. filters are called anti-aliasing filters.
We have discussed the basics DSP systems in this chapter. We had drawn a basic block diagram of a DSP system in
n
Fig. 1.5.1. We will now draw a modified block diagram of a DSP system and explain each block.
bl kn
at
Pu ch
Te
Fig.1.5.1
1. Input signal : A signal is defined as any physical quantity that varies with time, space or any other independent
variable. Anything that carries some information can be called a signal.
2. Anti-Aliasing Filter : Most of the naturally occurring signals are not band limited. This means that they have infinite
frequencies present in them. Anti-Aliasing filters are basically low pass filters which are used to remove the high
frequencies from the input signal thereby making them band limited.
3. Analog to Digital Converter (ADC) : As the name suggests, ADC converts a continuous time signal x(t) to a discrete
time signal x(n).
4. Digital Signal Processor (DSP) : This is the heart of the DSP system. It processes the discrete time input signal x(n) and
gives us the required discrete time output signal y(n). One could either use a computer or dedicated DSP’s
manufactured by companies such as Motorola and Texas Instruments.
5. Digital to Analog Converter (DAC) : The output of the DSP is in digital form but most of the output devices only work
in continuous time signals. DAC converts a discrete time signal y(n) to a continuous time signal y(t) which can be then
fed to the out device.
6. Reconstruction filter: The output of the DAC might contain high frequencies due to the interpolation of sinc functions.
These spurious high frequencies are eliminated using the reconstruction filter which is basically a low pass filter.
We will now solve a few examples to understand the sampling concepts.
DSIP (MU-Sem. 7-COMP) 1-14 Introduction to Digital Signal Processing
x (n) = sin 2 –
what is the discrete time signal obtained after sampling ? 3
Soln. :
4
x (n) = – sin
3
Given :
4 n
x (t) = sin (10 t) + 2 sin (20 t) + 2 cos (30 t)
Since Ideal interpolation is used, analog signal is
(i) This signal consists of following frequencies, obtained by replacing n by t Fs.
2F1 = 10, 2 F2 = 20 and 2F3 = 30 n = 80 t
ge
F1 = 5 Hz, F2 = 10 Hz, and F 3= 15 Hz
x (t) = – sin
3
Thus the maximum frequency present in the signal is, 4 80 t
x (t) = – sin (60 t)
io led
Fmax = W = 15 Hz
Hence a 50 Hz signal gets reconstructed as a 60 Hz
Nyquist rate = 2 Fmax = 30 Hz
signal.
(ii) The discrete time signal is obtained by substituting
ic ow
x (n) = sin 10
n
+ 2 sin 20
n
20 20 Obtain the discrete time signal if this sequence is sampled at
+ 2 cos 30
at
n FS = 400 Hz.
Pu ch
20
Does aliasing occur ? If yes, calculate the aliased
3
= sin frequencies from the original frequencies.
2 n + 2 sin ()n + 2 cos 2 n
Te
Soln. :
but, sin (n) = 0
3 Given :
also = 2 –
2 2 x (t) = cos (150 t) + 2 sin (300 t)
x (n) = sin n + 2 cos 2 – n – 4 cos (600 t) ...(1)
2 2
Here 2F1t = 150t, 2F2t = 300t and 2F3t = 600t
–
x (n) = sin
2 n + cos 2 n F1 = 75 Hz, F2 = 150 Hz, and F3= 300 Hz
but, Maximum frequency Fmax = 300 Hz
–
cos Thus the sampling frequency, required to avoid
2 n = cos 2 n =0 aliasing is,
x (n) = sin n Fs 2 Fmax
2
Fs 600 Hz
Ex.1.5.2 : A signal x (t) = sin (t ) of frequency 50 Hz is
The given signal is sampled at Fs = 400 Hz.
sampled using a sampling frequency of 80 Hz. Obtain the
recovered signal if ideal reconstruction is used.
Thus discrete signal is obtained by substituting
n n
Soln. : Given : t = = in Equation (1)
Fs 400
x (t) = sin t of frequency 50 Hz
n
x (t) = sin (2 50t) t =
400
Now , Fs = Sampling frequency = 80 Hz
DSIP (MU-Sem. 7-COMP) 1-15 Introduction to Digital Signal Processing
x (n) = cos
3 3 (ii) If this analog signal is sampled at
8 n + 2 sin 4 n Fs = 5000 samples/sec, what is the discrete-time signal
– 4 cos n
3
...(2) obtained after sampling ?
2
(iii) What is the analog signal ya(t) we can reconstruct from
3
The third terms of 2 can be written as the samples if we use ideal interpolation ?
Soln. :
– 4 cos 2 – 2 n.
Given :
= – 4 cos – n xa(t) = 3 cos 2000t + 5 sin 6000t + 10 cos 12000t …(1)
2
(i) The given signal consists of following frequencies,
but, cos n = cos
–
ge
2 2 n =0 2 F1 = 2000t, 2 F2 = 6000t, 2 F3 = 12000 t
F1 = 1000 Hz, F2 = 3000 Hz and F3 = 6000 Hz
x(n) = cos n + 2 sin n
3 3
8 4
io led Thus Fmax = 6000 Hz = 6 kHz
Hence aliasing does occur. Nyquist rate = 2 Fmax = 12 kHz
Ex.1.5.4 : An analog signal contains frequencies upto (ii) A discrete signal is obtained by substituting
ic ow
10 kHz n n
t = = in Equation (1)
Fs 5000
n
(i) What range of sampling frequencies allows exact
2000 n 6000 n
x(n) = 3 cos
bl kn
Fs = 8 kHz
Pu ch
5000
What is the folding frequency ?
x(n) = 3 cos n + 5 sin n
2 6
Examine what happens to the frequency F1 = 5 kHz 5 5
Te
+ 10 cos
Examine what happens to the frequency F2 = 9 kHz
12
5 n
Soln. :
The second term 5 can be written as,
6
(i) From the Nyquist criteria we know that,
Fs 2W
6 = 2 – 4
Fs 2 10 5 5
x(t) = 13 cos
2 4 xa (t) = 15 cos(1250 t) + 17 cos (2170 t) + 33 cos (4750 t).
5 5000 t – 5 sin 5 5000 t is converted to a discrete time signal. Determine the Nyquist
x(t) = 13 cos 2000 t – 5 sin 4000t. rate, Folding frequency, resulting discrete time signal x(n) if
the sampling frequency is 625 Hz. Also write the discrete
Ex. 1.5.6 : An analog signal is given by :
frequencies in radians
x (t) = 3cos (100 t) + 2 sin (300 t) – 4 cos (100 t)
Soln. :
(1) What is the Nyquist rate of the sigal.
Given
(2) Write the equation of the sampled signal
xa (t) = 15 cos(1250 t) + 17 cos (2170 t) + 33 cos (4750 t).
(3) If this analog signal is sampled at
This signal consists of following frequencies,
ge
Fs = 200 samples/sec, what is the discrete-time signal
obtained after sampling ? 2F1 = 1250, 2 F2 = 2170 and 2F3 = 4750
F1 = 625 Hz, F2 = 1085 Hz, and F 3= 2375 Hz
io led
Soln. : Given :
Thus the maximum frequency present in the signal is,
x (t) = 3cos (100 t) + 2 sin (300 t) – 4 cos (100 t)
Fmax = W = 2375 Hz
ic ow
Nyquist rate = 2 Fmax = 300 Hz The discrete time signal is obtained by substituting
ge
recovered from its samples ? MU - May 2018, 10 Marks
2. Image processing applications.
Soln. : (i)Nyquist rate
3. Robotic vision.
io led
Given : x (t) = 5 cos 2(1000)t + 10 cos 2(5000)t …(1) 4. Biomedical signal application like processing and
The given signal consists of following frequencies, analyzing ECG, EMG, CT, MRI, etc.
F1 = 1000 Hz and 5. Data compression.
ic ow
The continuous time signal had two different Q. 6 Draw and explain basic elements of DSP.
frequencies while the discrete time signal has only one. Q. 7 Explain Concept of Frequency in Discrete Time
(iii) The reconstructed signal is obtained by substituting Signals.
n = t Fs in the discrete time signal
2 Discrete Time Signal and System
Syllabus :
Classification of Discrete-Time Signals, Classification of Discrete- Systems
Linear Convolution formulation for 1-D and 2-D signal (without mathematical proof), Auto and Cross Correlation formula
evaluation, LTI system, Concept of Impulse Response and Step Response, Output of DT system using Time Domain
Linear Convolution
ge
Ex. 2.1.1 : Draw the graphical representation of the given
In chapter 1, we discussed the basics of digital signal signal x(n) = {1, 2, 2, 2, 3}
io led
processing. We also understood the method of obtaining a
discrete time signal form an analog signal. In this chapter Soln. : Since there is no arrow, the first element is the
we discuss various aspects of discrete time signals and origin.
ic ow
Signals
There are various methods of representing a discrete
at
Pu ch
time signal.
Fig. 2.1.1
Solved Example
ge
io led
ic ow
n
(a) (b) (c)
bl kn
There are a number of basic signals that we encounter regularly and which play an important role in signal processing.
Te
(b)
ge
io led
ic ow
Fig. 2.1.5
n
4. Exponential signal
bl kn
n
Pu ch
5. Sinusoidal signal
A discrete time sinusoidal signal is given by the
formula
x(n) = A cos ( n + )
Where A is the amplitude, is the frequency in
radians and is the phase.
An example of discrete-time sinusoidal signal is shown
in Fig. 2.1.7.
ge
io led Fig. 2.1.7 : A sinusoidal sequence
figure (3)
%Plot Unit Step, Unit Ramp, Exponential and Sinusoidal
stem (x3)
Functions
n
bl kn
%SINUSOIDAL SIGNAL
clc
at
clear all
w = input (‘enter the value of frequency for sinusoidal
function :’)
Te
%UNIT STEP
%Take w = 0.1*pi, 0.2*pi,….0.9* pi, pi
for n = 1 : 1 : 20% We take the length of the sequence to be
20 for n = 1 : 1 : 20
a = input (‘enter the value of a for exponential signal :’) 2. Periodic and Aperiodic signals
for n = 1 : 1 : 20 3. Energy and power signals
DSIP (MU - Sem.7- COMP) 2-5 Discrete Time Signal and System
2.2.1 Even and Odd Signals
A discrete time signal is said to be even (symmetric) if
it satisfies the following condition.
ge
io led
ic ow
Fig. 2.2.1
signal,
Note : sin (50) = – sin (– 50)
cos (50) = cos (– 50)
Most of the signals that we encounter are neither
purely even or odd but are a combination of both. In other
(b) Even signal
words any arbitrary signal can be expressed as a sum of
even signals and odd signals.
Fig. 2.2.2
DSIP (MU - Sem.7- COMP) 2-6 Discrete Time Signal and System
The even component is extracted by adding x(n) to
x(– n) and dividing by 2 i.e.
x(n) + x(– n)
xe(n) = …(2.2.3)
2
Similarly the even component is extracted by adding
x(n) to – x(– n) and diving by 2.
x(n) – x(– n)
Xo (n) = …(2.2.4)
2
Clearly Equation (2.2.3) satisfies the symmetric
condition in Equation (2.2.1) while Equation (2.2.4) satisfies (c)
the antisymmetric condition in Equation (2.2.2).
x (n) – x (– n)
Let us solve an example to understand this better. xo (n) =
2
Note : x (– n) is simplify the mirror image of x (n).
Solved Example
ge
Ex. 2.2.1 : Find the even and odd components of the
given discrete time signal
io led
x (n) = {1, 2, 3, 4 , 1, 2, 2}
Soln. : We shall solve this example graphically. To find the
ic ow
x (n).
signal ! !
at
Pu ch
Te
(a)
Fig. P. 2.2.1 (e)
(b)
Fig. P. 2.2.1 Fig. P. 2.2.1 (f)
x (n) + x (– n) x (n) = xe (n) + xo (n)
Now, xe (n) =
2
DSIP (MU - Sem.7- COMP) 2-7 Discrete Time Signal and System
Solved Examples
A signal is periodic if there exist N such that We have the standard equation,
ge
x (n + N) = x (n) io led …(2.2.5) x(n) = cos n …(2)
Let us take an example. Check whether Comparing Equations (1) and (2) we get,
x(n) = A cos (n + ) is periodic.
= 0.01
ic ow
x (n + N) = A cos (2f (n + N) + ) 2
Pu ch
Now,
For periodicity x (n + N) = x (n) 1
f = cycles per sample …(3)
200
Te
Hence a discrete time signal is periodic only if it’s Comparing Equations (3) and (4)
frequency is a rational number (ratio of two integers). Fundamental period = N = 200 samples
If the input signal is expressed as a summation of two (ii) Given :
signals i.e., x (n) = x1 (n)+ x2 (n), we calculate f1 and f2
k1 k2 x (n) = cos (3 n) …(5)
where, f1 = N and f2 = N
1 2 Comparing with Equation (2) we get,
N1
The resultant signal x (n) is periodic if N is a ratio of = 3
2
two integers.
2f = 3
The period of x (n) will be the LCM of N1 and N2.
3
A few examples would make things clear. f = cycles / sample …(6)
2
DSIP (MU - Sem.7- COMP) 2-8 Discrete Time Signal and System
Since `f' is ratio of two integers; the given sequence is A discrete time complex exponential is periodic if its
periodic. Comparing Equations (4) and (6) we get, relative frequency is a rational number. We have the
standard equation of a discrete time complex exponential.
Fundamental period = N = 2 samples
2kn
j N
(iii) Given sequence is, x (n) = e ...(2)
x (n) = sin 3 n …(7) Comparing Equations (1) and (2) we get,
Comparing with Equation (2) we get, 2kn 2k 1
= n =
= 3 N 4 N 4
2f = 3 k 1
3 =
N 8
f =
2
Since it is ratio of two integers; the given sequence is
Here 2 is not an integer. That means ‘f ’ cannot be
periodic. It’s fundamental period is N= 8 samples.
ge
expressed as the ratio of two integers. In this case f is
x2 ( n ) = 3 sin n
1
(ii) Given ...(3)
irrational. Thus the given sequence is non-periodic. 8
(iv) Given sequence is,
io led We have the standard equation,
x (n) = cos
n n x ( n ) = A sin n ...(4)
8 cos 8 ...(8)
Comparing Equations (3) and (4) we get,
ic ow
1
f =
Comparing Equations (8) and (9) we get, 16
at
Pu ch
1
1 = and 2 = Here is an irrational number hence f is not the ratio of two
8 8
integers. Thus given sequence is non-periodic.
Te
but, = 2 f
2.2.3 Energy and Power Signals
1
2 f1 = and 2 f2 = For a discrete time signal x (n), the energy is defined
8 8
as,
1 1
f1 = and f2 =
16 16 +
2
E = | x (n) |
Hence f1 is ratio of non-integer values. So it is non-periodic.
n=–
While f2 is ratio of two integer values. So it is periodic. But
the total signal is multiplication of non-periodic and The reason for using magnitude square is so that the
periodic signals. So the resultant signal x(n) is non-periodic. definition applies to real valued as well as complex valued
signals. If E is finite, then x (n) is called an energy signal.
Ex. 2.2.3 : Find if the following sequences are periodic or
Many signals that possess infinite energy have finite power.
not. If yes find its fundamental time period. The average power of a discrete time signal x (n) is defined
n
(i) 1
()
x (n) = e 4
j
(ii) x2 (n) = 3 sin (18 n )
as
N
Soln. : lim 1 2
P = | x (n) |
N 2N + 1
n
e (4 )
j
n=–N
(i) Given : x1 (n) = ...(1)
A signal x (n) is said to be a power signal if the average
power is finite.
DSIP (MU - Sem.7- COMP) 2-9 Discrete Time Signal and System
Solved Example n
E =
1
…(3)
Ex. 2.2.4 : Obtain energy for the signal x ( n ) = a u ( n )
n 4
n=0
where | a | < 1.
We have the standard geometric series formula,
Soln. : For D.T. signal, energy is given by,
1
A
n
= 1+A+A +…=
2
E = |x(n)|
2
...(1) n=0
1–A
n=–
1 4
The given equation of x ( n ) is, E = =
1 3
1–
n 4
x(n) = a u(n) ...(2)
Here u( n ) represents unit step. It’s value is one for i.e. E is finite.
the range 0 to . Hence multiplication by u ( n ) does not
n n Note : If 0 < E < then the signal is energy signal. Since
change the amplitude of a ; but it indicates that a is
ge
present only from n = 0 to n = . the calculated value of energy is finite; the given signal is
Thus Equation (1) reduces to, energy signal.
io led
Ex. 2.2.6 : Determine the energy and power of signal
E = | an |2 ...(3)
given by,
n=0
ic ow
E = [a ] ...(4)
n=0 Soln. :The energy of signal is given by,
at
E =
|x(n)|
2
… (1)
1 n=–
A = 1 + A + A + A + …. =
n 2 3
if | A | < 1.
Te
1–A n
n=0
The given signal is, x ( n ) = for the range n 0 and
1
2
Here A = a . Thus Equation (4) reduces to,
2
n
x ( n ) = 3 for n < 0. Thus Equation (1) becomes,
1
E =
2
2 if | a | < 1 n 2 –
1
E =
1–a
+ [3 ]
n 2
n
2
Ex. 2.2.5 : x ( n ) = ( 0.5 ) u ( n ). State whether it is an n=0 n=–1
energy or power signal. Justify. 2 n –
1
E =
2 + [ 3 ]
2 n
Soln. : First we will calculate the energy of signal x ( n ). It
n=0 n=–1
is given by,
n –
= + (9)
1 n
…(2)
E =
|x(n)|
2
… (1) 4
n=0 n=–1
n=–
Consider the first summation term. Using geometric series
The given signal is,
n formula we can express it as follows :
x ( n ) = ( 0.5 ) u ( n ) … (2)
n
Since it is multiplied by unit step; this signal is present from 1
4 =
1
=
4
…(3)
n = 0 to n = . Thus Equation (1) becomes, 1 3
n=0 1–
4
2n
E = [ ( 0.5 ) ] =
1 n 2 Now consider the second summation term. To make
2 the limits of the summation positive, put n = – m. The limits
n=0 n=0
change as follows.
DSIP (MU - Sem.7- COMP) 2-10 Discrete Time Signal and System
9
1 1/9 9 1
= = = …(4)
1–
1 8/9 8 2.3 Operation on Signals
m=1 9
ge
Putting Equations (3) and (4) in Equation (2) we get, It is imperative for students to understand simple
4 1 manipulation techniques on discrete time signals. Signal
E = + processing involves modifying the original signal. This
3 8
io led
modification is achieved by performing different operations
35
E = on discrete time signals. The mathematical transformation
24
from one signal to another is represented as,
ic ow
P = 0
1. Time shifting
Ex. 2.2.7 : Determine the energy and power of the signal 2. Time reversal
Te
Since there is u(n), we change the limits of summation Let us see what this equation amounts to.
n2
1 Solved Examples
E =
n=0
3
Ex. 2.3.1 : x (n) = {1, 2, 3, 4, 5}
n
9
1
E =
n=0 Find y (n) = x (n – 2)
DSIP (MU - Sem.7- COMP) 2-11 Discrete Time Signal and System
Fig. P.2.3.1
ge
y (n) = x (n – 2) io led y (n) = T [x (n)]
y (– 2) = x (0) = 1
y (2) = x (0) = 1 (∵ the value of x(n) at n = 0 is 1)
y (– 1) = x (1) = 2
n
y (3) = x (1) = 2
bl kn
y (0) = x (2) = 3
y (4) = x (2) = 3
y (1) = x (3) = 4
at
y (5) = x (3) = 4
Pu ch
Fig. P. 2.3.2(a)
Fig. P. 2.3.1(a)
We hence note that y (n + 2) shifts the output to the left.
Hence we state that y (n) = x (n – 2) is a right shifted This is known as time advance.
version of x (n) i.e., y (n) is a delayed version of x (n). Hence for y (n – k), if k is > 1 Right shift Time delay
Ex. 2.3.2 : x (n) = {1, 2, 3, 4, 5} if k is < 1 Left shift Time advance
Find y (n) = x (n + 2)
DSIP (MU - Sem.7- COMP) 2-12 Discrete Time Signal and System
2.3.2 Time Reversal Hence y (n) is a mirror image of x (n). It is a folded version
of x (n).
This is also known as the folding operation. It is We have used the time reversal operation while computing
mathematically given by the equation, the odd and even components of a signal.
y (n) = T [x (n)] 2.3.3 Time Scaling
y (n) = x (– n) This operation is related to change in time scale.
This can be very easily understood by taking the same There are two types of time scaling operations :
example. (a) Down scaling
ge
y (n) = x (2n)
We shall explain this with an example.
io led
Solved Example
Find y (n) = x (2n)
n
bl kn
Fig. P. 2.3.3
at
Pu ch
y (n) = T [x (n)]
y (n) = x (– n)
Te
Fig. P. 2.3.5
ge
(b) Up scaling : It is mathematically represented as,
In this operation, the entire signal is multiplied by a
y (n) = x (n / 2)
io led scalar. This is mathematically represented by,
We take the same example. y (n) = T [x (n)]
Solved Example i.e., y (n) = x (n)
This results in amplification of the signal.
ic ow
Ex. 2.3.6 :
y(n) = T[x(n)]
at
y (n) = x (n / 2)
Pu ch
y (0) = x (0) = 1
y (1) = x (1/2) = No sample We take different values of n
Let us solve an examples to make things clear. Ex. 2.3.8 : Draw u(n) – u(n – 5)
Soln. :
2.3.6 Solved Examples on Signals
u(n) is a unit step while u(n – 5) is a unit step shifted
Ex. 2.3.7 : Given two signals x1 (n) = {1, 1, 0 , 1, 1} and
by 5 to the right. We draw them one below the other and
perform subtraction.
x2 (n) = {2, 2, 0 , 2, 2}.
Perform (i) x1 (n) + x2 (n) (ii) x1 (n) x2 (n)
Soln. : The first step is to place the two signals exactly one
ge
below the other.
Fig. P.2.3.8
io led
ic ow
n
Fig. P.2.3.7
bl kn
Fig. P.2.3.8(a)
at
Pu ch
Te
Fig. P.2.3.7(a)
Fig. P. 2.3.8(b)
Soln. :
We begin with drawing x(n).
Fig. P. 2.3.7(c)
Bear in mind that we add / multiply only the
corresponding terms.
DSIP (MU - Sem.7- COMP) 2-15 Discrete Time Signal and System
Fig. P. 2.3.9
ge
(iii) x(n – 1) u(–n – 1)
x(n + 1) = {3, 2, 1 , 6, 4, 5}
io led
ic ow
n
bl kn
at
Pu ch
Te
Fig. P.2.3.9(e)
Fig. P.2.3.9(a)
Fig. P.2.3.9(f)
Fig. P.2.3.9(b)
Fig. P.2.3.9(g)
Fig. P.2.3.9(c)
DSIP (MU - Sem.7- COMP) 2-16 Discrete Time Signal and System
(iv) x(n – 1) u(n) Ex. 2.3.10 : For x(n) = {1, 2, –1, 5, 0, 4}, plot the following
discrete time signals.
(i) x(n + 3) (ii) x(–n – 2)
(iii) x(n – 2) (n – 2) (iv) x(2n)
MU - Dec. 2018, 10 Marks
Soln. : We begin with drawing x(n)
Fig. P.2.3.9(h)
ge
io led
Fig. P.2.3.10
Fig. P.2.3.9(i)
ic ow
(i) x(n + 3)
n
This is x(n) shifted to the left by 3.
bl kn
at
Pu ch
Te
Fig. P.2.3.9(j)
(v) x(n – 2)
Fig. P.2.3.10(a)
This is x(n) shifted to the right by 2.
(ii) x(–n – 2)
Fig. P.2.3.9(k)
Fig. P.2.3.10(b)
DSIP (MU - Sem.7- COMP) 2-17 Discrete Time Signal and System
ge
(ii) y (n) = log x (n)
(iii) y (n) = A cos x (n)
In each case, y (n) requires only the present value of
io led
input x (n)
Fig. P.2.3.10(d) i.e. from y (n) = log x (n), we write
ic ow
Fig. P.2.3.10(e)
depends on the present as well as past inputs.
(iv) x(2n)
For example, y (n) = x (n) + x (n – 2)
Te
This is time compression also known as down In this case, to find out y (4), we need x (4) which is the
sampling. present input as well as x (4 – 2) = x (2) which is the
past input. Hence to find out entire y (n), we need
present inputs as well as part inputs.
Some examples of Dynamic systems are :
x (n) + x (n – 12)
1. y (n) = 2
2. y (n) = x (n) – x (n – 1)
Fig. P.2.3.10(f)
Since past input values need to be stored and
2.4 Discrete Time Systems retrieved, the system requires a certain amount of
memory. Hence Dynamic systems are also called
memory systems.
As defined earlier, a discrete time system is a device or
an algorithm that operates on a discrete time signal. It is 2. Causal and Non-causal system
mathematically represented as y (n) = T [x (n)]
A system is said to be causal if the output of the
Discrete time systems are classified according to their system y (n) at any time n depends only on present
general characteristics. and past inputs but does not depend on future inputs.
1. Static and Dynamic system (Memory less and Memory i.e. y (n) = x (n) + x (n – 2) + x (n – 16)
systems) If the output of a system also depends on future inputs
2. Causal and Anti-causal system it known as a Non-Casual systems.
DSIP (MU - Sem.7- COMP) 2-18 Discrete Time Signal and System
For example, y (n) = x (n) + x (n + 1) Here the system multiples the input x(n) with n.
In this case, to find out say y (4), we need x (4) which is We use two inputs, x1(n) and x2(n)
the present input as well as x (5) which is the future We check if T [x1 (n) + x2 (n)] = T [x1 (n)] + T [x2 (n)]
input. (1) T[x1(n) + x2(n)]
Hence in an non-causal system, we need to predict the
future inputs to get the present input. Given below are
a few examples of Causal and Non-Causal systems.
x (n) + x (n – 1) + x (n – 2)
1. y (n) = 3 causal
ge
A system is said to be linear if it satisfies the
superposition principle.
io led
Superposition principle states that the response of the
system to a weighted sum of signals is equal to the
corresponding weighted sum of output of the system
ic ow
Fig. P. 2.4.1(a)
Fig. 2.4.1
Note : The system T is said to be linear if y1 (n) = y2 (n). Hence the system in this case computes the exponential
of the input.
Solved Example
We use two inputs, x1 (n) and x2 (n)
Ex. 2.4.1 : Check whether the following systems are linear
We check for T [x1 (n) + x2 (n)] = T [x1 (n)] + T [x2 (n)]
or non linear.
1. y (n) = n x(n)
x(n)
2. y (n) = e
2
3. y (n) = x (n)
(a) (b)
Fig. P.2.4.1(c) Fig. 2.4.3
x1(n) x2(n)
y2 (n) = e To check whether the system in Time invariant or not,
Hence y1 (n) y2 (n); Hence system is unstable. we perform the following steps :
2 Step 1 : Delay input x (n) by k samples and observe the
ge
(3) y (n) = x (n)
output. We call this output y (n, k).
We know y (n) = T [x (n)]
Step 2 : Delay the output y (n) by k samples i.e., in the
io led
Hence the system computes the square of the input
given equation y (n), replace n by (n – k). We call
x(n).
this output y (n – k).
We use to inputs x1 (n) and x2 (n) and check it
If y (n, k) = y (n – k) the system is said to be time
ic ow
T [x1 (n) + x2 (n)] = T [x1 (n)] + T [x2 (n)] invariant or else it is called time variant.
Solved Example
n
bl kn
x(n)
Pu ch
Soln. :
y1(n) = [x1(n) + x2(n)]2
x(n)
1. y (n) = e
Now,
We know y (n) = T [x (n)]
Fig. P.2.4.2
Fig. P. 2.4.1(e)
Fig. P.2.4.2(a)
2 2
y2 (n) = x1 (n) + x2 (n)
y (n, k) = e
x (n – k)
Fig. P.2.4.2(b)
DSIP (MU - Sem.7- COMP) 2-20 Discrete Time Signal and System
y (n – k) = e
x (n – k)
Fig. P.2.4.2(d)
Step 2 : Delay the output
ge
io led Fig. P.2.4.2(e)
Since, y (n, k) = y (n – k), the system is Time Invariant.
3. y (n) = n x (n)
y (n) = T [x (n)] Fig. P.2.4.2 (f)
ic ow
= n x (n – k)
Pu ch
y (n, k)
y (n – k) = (n – k) x (n – k)
Since y (n, k) y (n – k), the system is Time Variant. Fig. P.2.4.2 (h)
ge
Corel 2 Corel 3
io led Fig. 2.5.1
Fig. 2.4.6
x(–1) ; for n = –1
i.e., x(–1) . (n + 1) = h (n) = T [ (n)]
0 ; for n –1
at
Pu ch
In a similar manner
i.e. , x (n) = x (k) (n – k)
k=–
x(–2) ; for n = –2
x(–2) . (n + 2) =
0 ; for n –2 We know,
x(–3) ; for n = –3
x(–3) . (n + 3) =
0 ; for n –3 y (n) = T [x (n)]
x(1) ; for n = 1
x(1) . (n – 1) =
0 ; for n 1
+
= T x (k) (n – k)
y (n) …(2.5.1)
x(2) ; for n = 2
x(2) . (n – 2) = k = –
0 ; for n 2
x(3) ; for n = 3 If we assume the system to be linear, then
x(3) . (n – 3) =
0 ; for n 3 Equation (2.5.1) can be written as,
ge
xh = Highest range of x(n)
This equation is called the convolution sum and is one
of the most important formula in Digital Signal hl = Lowest range of h(n)
io led
Processing and Image Processing applications. hh = Highest range of h(n)
It states that for a Linear Time-Invariant (LTI) system, if
The range of n is y(n) will be equal to
ic ow
Range of k
ge
Ex 2.5.2 : Consider an audio signal x(n) = {1, 2, 4}. This
signal is filtered using a low pass filter having an impulse
io led Fig. P. 2.5.2(a)
response h(n) = {1, 1, 1}. Obtain the filtered output signal.
Soln. : Filtering a signal implies the convolution operation. y(0) = x(k) h(–k) = 1 1 = 1
ic ow
Always remember this. The filtered output is given by the (2) Shift h(– k) to the right
formula.
n
y(n) = x(n) * h(n)
bl kn
+
i.e. y(n) = ∑ x(k)h(n–k)
at
Pu ch
k=–
Fig. P. 2.5.2(b)
+
y(0) = ∑ x(k)h(–k)
k=–
i.e. we need x(k) and h(– k)
The steps involved are as follows :
Fig. P. 2.5.2(i)
Fig. P. 2.5.2(e)
ge
io led Fig. P. 2.5.2(j)
y(–1) = 0
y(1) = x(k) h(–1 – k) = 0
ic ow
y(n) = {1, 3, 7 , 6, 4}
Now for the 5thshift we have
Hence the filtered audio signal is y(n) = {1, 3, 7, 6,4}.
Te
= 3+3–1=5
Fig. P. 2.5.3(d)
y(3) = 2 (– 1) + 3(2) + 1(2) = 6
Fig. P. 2.5.3
ge
Fig. P. 2.5.3(e)
io led
y(4) = 3(– 1) + 1(2) = – 1
ic ow
Fig. P. 2.5.3(a)
n
y(0) = 1(2) + 2(1) = 4
bl kn
y(5) = 1(– 1) = – 1
beyond this there will be no overlap between x(k) and
Te
Fig. P. 2.5.3(b)
Fig. P. 2.5.3(g)
Fig. P. 2.5.3(c)
y(–1) = 1(1) =1
DSIP (MU - Sem.7- COMP) 2-26 Discrete Time Signal and System
Fig. P. 2.5.3(i)
y(–2) = 0
ge
Fig. 2.5.4
length of y(n) = length of x(n) + length of h(n) – 1
Step 3 : We separate the elements diagonally
= 4+4–1=7
io led
We shade the section where the arrows intersect. In
We observe that y(n) obtained has 7 elements this case the arrows intersect at x(1)h(0) hence we have
shaded the entire diagonal section.
ic ow
Also
x(n) h(n) = y(n)
n
x(n) = 1 + 2 + 3 + 1 = 7
bl kn
h(n) = 1 + 2 + 2 – 1 = 4
at
x(n) h(n) = 7 4 = 28
Pu ch
Now y(n) = 1 + 4 + 9 + 10 + 6 – 1 – 1 = 28
Te
ge
io led
Fig. P. 2.5.5
y(n) = {1, 4, 8, 8, 3, – 2, – 1}
ic ow
h(n) = 1 + 2 +1–1 = 3
x(n)h(n) = 73 = 21
We check whether this result is correct.
Now y(n) = 1 +4 +8 +8 + 3–2 – 1
Length of y(n) = Length of x(n) + Length of h(n) – 1 = 21
Our result is correct.
= 5+4–1=8
ge
We will use one of the important properties of
x2 ( n ) = { 1 , 2, 1, 1 }
correlation. It is as follows :
io led
rxy ( l ) = x ( n ) * y ( – n ) …(2.6.1) We use the tabular method.
ic ow
Fig. P. 2.6.1
DSIP (MU - Sem.7- COMP) 2-29 Discrete Time Signal and System
Q. 6 With example explain the time scaling and time
Review Questions
reversal operations performed on discrete time
signals.
Q. 1 Define discrete time system. Explain any three
properties with suitable example. Q. 7 With example, explain how linear convolution can be
obtained using graphical method.
Q. 2 Define a periodic signal
Q. 8 Explain in brief different properties of convolution.
Q. 3 Define : Even signal and Odd signal
Q. 9 Explain why the result of linear and circular
Q. 4 Define power signal. convolution is not same.
Q. 5 Sketch and define two standard DT signals (n) and Q.10 How N point circular convolution can be obtained
u(n). using linear convolution ?
ge
io led
ic ow
n
bl kn
at
Pu ch
Te
3 Discrete Fourier Transform (DFT)
Syllabus :
Introduction to DTFT, DFT, Relation between DFT and DTFT, IDFT, Properties of DFT without mathematical proof
(Scaling and Linearity, Periodicity, Time Shift and Frequency Shift, Time, Reversal, Convolution Property and Parsevals‘
Energy Theorem). DFT computation using DFT properties. Transfer function of DT System in frequency domain using
DFT. Linear and Circular Convolution using DFT, Convolution of long sequences, Introduction to 2-D DFT Circular
Convolution (without mathematical proof), Linear convolution using Circular Convolution. Spectral Analysis using FFT
ge
Since colours are nothing but wavelengths and
3.1 The Fourier Transform
io led wavelengths are related to frequency, splitting of
white light into different colours is actually a form of
Fourier transform is named after the French
frequency analysis. Newton then placed another prism
mathematician Jean Baptiste Joseph Fourier who was
ic ow
Fig. 3.1.3
ge
is used when the signal is discrete in time and is a
periodic. It is given by the formula.
+
io led Fig. P. 3.2.1
– jn
X () = x (n) e
n= 1 ; n=0
(n) =
0 ; otherwise
ic ow
– jn
frequency components present in the signal. X () = x (n) e
n=–
at
+
Discrete Time Fourier Transform (I.D.T.F.T), It is given – jn
X () = (n) e
by the formula, n=–
Te
+
Since (n) exists only at n = 0.
∫ X()
1 + jn
x (n) = e d
2
– X () = – jn
1. e =1e
jo
n=0
Here we use the integral operation because X() is
continuous. X () = 1
FT
The DTFT does not exist for every periodic sequence. A (n) 1
sufficient condition for the existence of the DTFT for a
Ex. 3.2.2 : Obtain DTFT of a unit step signal u(n)
periodic signal x(n) is.
+ Soln. : A unit step signal is shown in Fig. P. 3.2.2.
| x (n) | <
n=–
– jn n=0
X () = x(n) e
n=– We know from the geometric of progression formula.
N
Since u(n) exists only for n ≥ 0, we change the limits of the 2
aN1 – a0N2 – 1
n
summation. a =
1–a
K=N
1
– jn
X () = e
Here N1 = 0, and N2 = L – 1
n=0
X () = A
1 – e j L
– j n
= (e ) 1 – e – j
n=0
FT 1 – e –jL
Rectangular pulse A A –j
We know from the geometric progression formula, 1–e
ge
n 1 Ex. 3.2.4 : Obtain DTFT and sketch the magnitude spectrum
a = |a|<1
1–a
n=0 for,
1
io led
x () = X (n) = u (n) – u (n – 4)
1 – e– j
FT 1 Soln. :
u (n)
ic ow
x (n) = A Hence,
0 n L–1 = 0 ; otherwise
at
Pu ch
Fig. P. 3.2.4
Fig. P. 3.2.3
DSIP (MU-Sem.7-COMP) 3-4 Discrete Fourier Transform (DFT)
– jn
x () = 1. e N –1 – j 2kn
n=0 X (k) = x(n)e
… (3.3.3)
n=0
Since the limits of the summation are small, we open up the
summation. N is normally equal to the length of the input signal x (n)
– jo – j1 – j2 – j3 Equation (3.3.3) is called the DFT and is one of the most
X () = e +e +e +e
– j – j2 – j3
important transforms in engineering.
X () = 1 + e
ge
+e +e
3.4 Discrete Fourier Transform (DFT)
We need to sketch the magnitude spectrum, io led
– j
e = cos – j sin The DFT is a modification of the Fourier transform so
– j
|e | = cos2 + sin2 = 1 as to use it for discrete time signals and to obtain a
discrete frequency spectrum. We shall now proceed to
ic ow
– j3
and |e | = cos2 3 + sin2 3 = 1 frequencies present in the signal.
Consider a discrete time input signal x(n) of length N.
| X () | = 1 + 1 + 1 + 1 = 4
at
Pu ch
Te
k = 0, 1, 2, N – 1 (3.4.1)
Since the input signal x(n) is of length N, the
summation varies from 0 to N – 1 and Equation (3.4.1)
is called as N-point DFT.
As mentioned in the earlier section, Equation (3.4.1)
Fig. P. 3.2.4(c)
acts as the prism, breaking down the input signal into
Note : The spectrum is continuous. various frequency components.
We can obtain x(n) from X(k) using the Inverse
3.3 Relationship between DTFT and
Discrete Fourier Transform IDFT which is given by the
DFT
formula,
N–1 + j 2kn
The DTFT is given by the formula, 1
x(n) = X(k) e
+
N
k=0
– jn
X (k) = x (n) e … (3.3.1) n = 0, 1, 2, N – 1 (3.4.2)
n=
Equation (3.4.2) is called as N–point IDFT.
Since the DTFT is continuous, we sample the axis to
make it discrete.
DSIP (MU-Sem.7-COMP) 3-5 Discrete Fourier Transform (DFT)
This acts as the inverted prism which gives us the Ex. 3.4.2 : Obtain DFT of (n – n0).
original signal x(n) by combining the constituent Soln.: Here x(n) = (n – n0)
frequencies. (n – n0) is basically (n) shifted to the right by n0.
1
Note : (n – n0) is 1 at n0 and 0 at all other values of n.
N in Equation (3.4.2) is a scaling function.
ge
The DFT is given by the equation,
Unless specified the length of x(n) and X(k) are the N–1 – j 2kn
limits of the summation depending on the input signal. Since (n – n0) exist at n = n0, for all other values of
n
bl kn
Ex. 3.4.1 : Obtain DFT of a unit impulse signal (n). the summation, the result will be equal to zero.
Soln.: Here x(n) = (n) – j 2 k n0
at
Pu ch
X(k) = (n – n0) e N
The DFT is given by the equation,
N–1 – j 2kn – j 2 k n0
; k = 0, 1, N – 1
Te
(ii) k = 1
3 – j21 · n
X(1) = x(n) e 4
n=0
– j21 · 0 – j21 · 1
4 4
= x(0) e + x(1) e
– j21 · 2 – j21 · 3
4 4
+ x(2) e+ x(3) e
Fig. P.3.4.3(a)
–j
= x(0) e0 + x(1) e 2
–j3
+ x(2) e –j + x(3) e 2
–j –j3
= 1+1·e 2 + 1·e –j + 1·e 2
ge
= 1 + 1 cos – j sin
Fig. P.3.4.3(b) 2 2
= 1–j–1+j
x(n) = { 1, 1, 1, 1} X(1) = 0
n
(iii) k = 2
bl kn
– j 2kn 4
; k = 0, 1, 2, N – 1
X(2) = x(n) e
at
X(k) = x(n) e
Pu ch
n=0
n=0
– j22 · 0 – j22 · 1
We now change the limits of the summation as x(n) = x(0) e 4
+ x(1) e 4
Te
= 1 + 1 cos – j sin
=
3 3
x(0) + x(1) + x(2) + x(3) 2 2
= 1 + 1 · (0 + j) + 1 (– 1 – 0) + (0 – j) X (0) = 1
= 1+j–1–j
= 0 For k = 1
X(3) = 0 2 – j2n
n=0
X(k) = {4, 0, 0, 0} – j2 – j4
DFT 0
X (1) = x (0) e + x (1) e 3
+ x (2) e 3
Hence, {1, 1, 1, 1} {4, 0, 0, 0} – j2 – j4
Let us draw the two sequences obtained. X (1) = 1 – 1 e 3
+1e 3
For k = 2
ge
2 – j2n
X (2) = x(n) e 3
io led
Fig. P.3.4.3(c) n=0
– j4 – j8
Soln.:
(ii) N = 4
at
Pu ch
(i) N=3
The range of ‘n’ is n = 0 to 3.
The range of ‘n’ is n = 0 to N – 1 that means n = 0 to 2. The sequence x(n) can be written as,
Te
X (k) = x(n) e 3
…k = 0 to 2 n=0
n=0 3 3
For k = 0 For k = 0 X (0) = x(n) e = 0
x(n)
2 – j20n
n=0 n=0
X (0) = x(n) e 3
X (0) = x (0) + x (1) + x (2) + x (3)
n=0 = 1–1+1–1
X (0) = x (0) e0 + x (1) e0 + x (2) e0 X (0) = 0
X (0) = x (0) + x (1) + x (2) = 1 – 1 + 1
DSIP (MU-Sem.7-COMP) 3-8 Discrete Fourier Transform (DFT)
– j 2 k n0
For k = 1
DFT N
3 – jn
And (n – n0) e
X (1) = x(n) e 2
DFT
– j 2 k·2
4
n=0 3 (n – 2) 3 e = 3e–jk
–j – j 2 k·3
–j 3 k
2 –j DFT 4
0
X (1) = x (0) e + x (1) e + x (2) e and 2 (n – 3) 2 e = 2e
2
– j3
+ x (3) e 2 DFT of the given sequence is,
ge
2
n=0
Thus given sequence can be written as,
X (2) = x (0) e0 + x (1) e– j + x (2) e– j2 + x (3) e– j3
+ j 2 k0 n – j 2 k0 n
1
io led
X (2) = 1 – (– 1 – j 0) + (1) (1 – j 0) – 1 (– 1 – j 0) x (n) = e
N
+e
N
2
X (2) = 4
According to the definition of DFT,
ic ow
For k = 3
N–1 –j2kn
3 N
n
– j3n X (k) = x(n) e
2
bl kn
N N
e N
Pu ch
1
X (3) = 1 – (0 + j 1) + (– 1 – j 0) – (0 – j 1) X (k) =
2 e N e
N
X (3) = 0 n=0
n=0
Ex. 3.4.5 : Obtain the DFT of the sequence n
x(n) = (n) + 3 (n – 2) + 2 (n – 3) 1 j 2 ( nk0 – k )
N–1
2
X (k) = e
Soln. : The given sequence is shown below. The length of
n=0
the sequence is from 0 to 3.
N – 1 – j 2 ( k0 + k ) n
1
N = 4 +
2 e
N
DFT n=0
We know, (n) 1
Now we have standard summation formula,
N2 a N1 – a N2 + 1
a1
an = 1–a
n = N1 N2 – N1 + 1 a = 1
0 N–1+1 – j 21 · 0 – j 21 · 1
j 2 (k0 – k)
j 2 ( Nk0 – k ) 4 4
1 e –e
N = x(0) e + x(1) e
X (k) =
2 j2 (k0 – k) – j 2 1 · 2 – j 21 · 3
4 4
N + x(2) e + x(3) e
1–e
– j
– j 2 (k0 + k) 0 – j 2 (k0 + k) N – 1 + 1
= x(0) e0 + x(1) e 2
+ x(2) e–j
1 e – e
N N
+ – j 3
2 – j 2 (k0 + k) 2
+ x(3) e
1–e
N
= 1 · 1 + 2 cos – j sin
j 2 (k0 – k) – j 2 ( k0 + k ) 2
1 1 – e 1 1 – e 2
= j2
+ –j2
+ 3 [cos – j sin ]
2 2
(k0 – k) ( k0 + k )
1–e N 1–e N
+ 4 cos – j sin
3 3
2 2
Ex. 3.4.7 : Compute the DFT of x(n) = {1, 2, 3, 4}. Draw
the corresponding magnitude and phase spectrum. = 1 + 2 (0 – j) + 3 (– 1 – 0) + 4 (0 + j)
ge
Soln.: x(n) = {1, 2, 3, 4} = 1 – 2j – 3 + 4j
io led X(1) = – 2 + 2j
(iii) k = 2
3 – j 22 · n
X(2) = x(n) e 4
n=0
ic ow
– j 22 · 0 – j 22 · 1
4 4
= x(0) e + x(1) e
n
– j 22 · 2 – j 22 · 3
bl kn
4 4
+ x(2) e + x(3) e
Fig. P.3.4.7 = x(0) e0 + x(1) e–j + x(2) e–j2+ x(3)e–j3
at
= 1 · 1 + 2 (cos – j sin )
Pu ch
4
; k = 0, 1, , N – 1 + 4 (cos 3 – j sin 3)
Te
X(k) = x(n) e
n=0 = 1 + 2 (– 1 – 0) + 3 (1 – 0) + 4 (– 1 – 0)
Since the length of x(n) is 4, N = 4 = 1–2+3–4
3 – j 2k n X(2) = – 2
X(k) = x(n) e 4
; k = 0, 1, 2, 3, (iv) k = 3
n=0
3 – j 23 · n
For each value of k, we vary n from 0 to 3. X(3) = x(n) e 4
n=0
(i) k = 0
– j 23 · 0 – j 23 · 1
3 – j 20 · n 4 4
x(n) e
= x(0) e + x(1) e
X(0) = 4
– j 23 · 2 – j 23 · 3
n=0 4 4
+ x(2) e + x(3) e
– j 20 · 0 – j 20 · 1
3 9
4 4 –j –j
= x(0) e + x(1) e = x(0) e0 + x(1) e 2 + x(2) e–j3 + x(3) e 2
– j 20 · 2 – j 20 · 3
= 1 · 1 + 2 cos – j sin
4 4
3 3
+ x(2) e + x(3) e 2 2
= e0 + 2 · e0 + 3 · e0 + 4 · e0
+ 3 (cos 3 – j sin 3) + 4 cos – j sin
9 9
= 1+2+3+4 2 2
= 1 + 2 (0 + j) + 3 (– 1 – 0) + 4 (0 – j)
X(0) = 10
= 1 + 2j – 3 – 4j
(ii) k = 1
X(3) = – 2 – 2j
3 – j 21 · n
X(1) = x(n) e 4 Hence the final DFT of x(n) is,
n=0 X(k) = { 10, – 2 + 2j, – 2, – 2 – 2j }
DSIP (MU-Sem.7-COMP) 3-10 Discrete Fourier Transform (DFT)
As is evident, the DFT is complex. (As in most practical cases) and hence can be split into magnitude and phase we
know,
Magnitude = (Real)2 + (Imaginary)2 and
Phase = tan–1
Imaginary
Real
X(k) = { 10, 2.83, 2, 2.83}
X(k) = { 0, 135 , 0, – 135}
We now draw the magnitude and phase. They are known as magnitude spectrum and phase spectrum.
ge
io led
ic ow
n
bl kn
at
Pu ch
Fig. 3.4.7(a)
Te
N N For k = 0
Note : We have drawn a dotted line at 2 (since N = 4, 2 = 2)
4 4
which we will explain later.
X (0) = x (n) e
0
= x (n)
Ex. 3.4.8 : Find N = 5 point DFT for x(n) = { 1,0,1,0,1 }. n=0 n=0
Soln. : X (0) = x (0) + x (1) + x (2) + x (3) + x (4)
= 1+0+1+0+1
Given : x(n) = {1, 0, 1, 0, 1} and N = 5
X (0) = 3
This is a five point DFT. For k = 1
N–1
X (1) = x (n) e 5
– j2kn n=0
X (k) = x (n) e N , k = 0 to N – 1
– j2
n=0
X (1) = x (0) e + x (1) e 5
0
ge
We have standard summation formula,
X (2) = 0.5 + j1.54
N2 N1 N +1
a –a 2
For k = 3
ak =
io led 1–a
4 – j6n k = N1
X (3) = x (n) e 5 – j2k
ic ow
n=0
Here N1 = 0, N2 = L – 1 and a = e N
– j6
X (3) = x (0) e + x (1) e 5
0
e
– j2k0 – j2kL – 1 + 1
n
– j12 – j18 – j24
N – e N
bl kn
1–e N
Pu ch
X (k) = A
4
– j2k
1–e N
– j8n
X (4) = x (n) e 5
n=0
– j8 – j16
Ex. 3.4.10 : Derive DFT of the sample data sequence
X (4) = x (0) e + x (1) e 5 + x (2) e 5
0
– j24 – j32
x(n) = {1, 1, 2, 2, 3, 3} and compute magnitude and
+ x (3) e 5 + x (4) e 5 phase spectrum.
10 k
–j
+ x (5) e 6
For k = 0
X (0) = x (0) e0 + x (1) e0 + x (2) e0 + x (3) e0 + x (4) e0 + x (5) e0
X (0) = 1 + 1 + 2 + 2 + 3 + 3 = 12
If k = 1
2 4 6 8 10
–j –j –j –j –j
X (1) = x (0) + x (1) e 6 + x (2) e 6 + x (3) e 6 + x (4) e 6 + x (5) e 6
X (1) = 1 + 1 cos – j sin + 2 cos – j sin + 2 (cos – j sin )
2 2
3 3 3 3
ge
+ 3 cos – j sin + 3 cos – j sin
4 4 5 5
3 3 3 3
X (1) = – 1.5 + j 2.6
io led
For k = 2
4 8 12 – 16 – 20
–j –j –j
6 + x (2) e 6 + x (3) e 6 + x (4) e 6 + x (5) e 6
ic ow
+ 3 cos
10 10
– j sin
3 3
at
Pu ch
For k = 3
X (3) = 1 + 1 (cos – j sin ) + 2 (cos 2 – j sin 2) + 2 (cos 3 – j sin 3 ) + 3 (cos 4 – j sin 4)
+ 3(sin 5 – j sin 5 )
X (3) = 0
8 16 24 32 40
–j –j –j –j –j
For k = 4 X (4) = x (0) + x (1) e 6 + x (2) e 6 + x (3) e 6 + x (4) e 6 + x (5) e 6
8 8
X (4) = 1 + 1 cos – j sin + 2 cos
4 4
– j sin + 2 (cos 4 – j sin 4 )
3 3 3 3
16 16 20 20
+ 3 cos – j sin + 3 cos – j sin
3 3 3 3
X (4) = – 0.5 – j 0.86
10 20 30 40 50
–j –j –j –j –j
For k = 5 X (5) = x (0) + x (1) e 6 + x (2) e 6 + x (3) e 6 + x (4) e 6 + x (5) e 6
X (5) = 1 + 1 cos
5 5 10 10
3 – j sin 3 + 2 cos 3 – j sin 3 + 2 (cos 5 – j sin 5 )
20 20 25 25
+ 3 cos – j sin + 3 cos – j sin
3 3 3 3
X (5) = – 1.5 – j 2.6
DSIP (MU-Sem.7-COMP) 3-13 Discrete Fourier Transform (DFT)
X(k) = {12, – 1.5 + j 2.6, – 1.5 j 0.86, 0, – 1.5 – j 0.86, – 1.5 – j 2.6}
ge
io led
ic ow
n
bl kn
at
Fig. P. 3.4.10
Te
Note : Observing the magnitude and phase plot of Ex. 3.4.7 Solved Examples
and Ex. 3.4.10 we note that
Ex. 3.5.1 : Given x(n) = {8, 2, 1, 5, 6, 2, 4, 3}
N
1. The magnitude plot is symmetric about the 2 point. If N is The DFT of this signal is
N+1 X(k) = { 31, 0.58 + 1.58 j, 9 + 4j, 3.41 – 4.4 j, 7, 3.41 + 4.4 j,
odd, then it is symmetric about the 2 point.
9 – 4 j, 0.58 – 1.58j }
N
2. The phase plot is anti-symmetric about the 2 point. If N is Verify this by a program or by using the fft(x) command in
N+1 MATLAB.
odd, then it is anti-symmetric about the 2 point.
Soln. : Since X(k) is complex, it has magnitude and phase.
This is always true. We plot its Magnitude.
|X(k)| = {31, 1.69, 9.84, 5.58, 7, 5.58, 9.84, 1.69}
3.5 The Fourier Spectrum
ge
The DFT is basically sampling of the frequency axis.
Suppose x(n) was obtained by sampling x(t) with a
Fig. P. 3.5.1(b)
io led
sampling frequency of 8000 Hz.
Hence we state what has been stated earlier.
A 8 point DFT will split this sampling frequency into 8
The entire area of Digital Signal Processing makes
ic ow
equal parts.
sense only if we know the sampling frequency. Only if
Fs
k k = 0, 1, 2, …, 7 we know the sampling frequency, will we be able to
n
N
bl kn
Fig. P.3.5.1(a)
Solved Example
Hence we state that x(n) is made up of a DC value of
31, 1 Hz signal with magnitude 1.69, 2 Hz signal with Ex. 3.6.1 : Compute the IDFT of X(k) = {4, 0, 0, 0}
magnitude 9.84, 7 Hz signal with magnitude 1.69. Soln.: IDFT is given by the equation,
If we change the sampling frequency, the X-axis N-1 + j 2kn
1
changes !! x(n) =
N X(k) e
N
; n = 0, 1, N – 1
k=0
Suppose x(n) was obtained by sampling x(t) with a
sampling frequency of 10 kHz. Since length of X(k) is 4, N = 4
3 + j 2kn
1
A 8-point DFT will split up the X-axis by the formula,
x(n) =
4 X(k) e
4
; n = 0, 1, 2, 3
Fs k=0
k ; k = 0,1, 2, …, 7
N For each value of n, we vary k from 0 to 3
DSIP (MU-Sem.7-COMP) 3-15 Discrete Fourier Transform (DFT)
1
+ j 20 · 3 + j 2 · 3
(i) n = 0
= X (0) e
4 4
+ X (1) e
3 + j 2k · 0 4
1
x(0) =
4 X(k) e
4
+ j 22 · 3 + j 23 · 3
k=0
+ X (2) e
4
+ X (3) e
4
1
+ j 20 · 0 + j 2 · 0
=
4
X (0) e 4
+ X (1) e
4
3
1 j
= [ 4e0 + 0 · e 2 + 0 ej3 + ej9 ] = 1
4
+ j 22 · 0 + j 23 · 0
+ X (2) e
4
+ X (3) e
4
1 x(3) = 1
= [ X(0) e0 + X(1) e0 + X(2) e0 + X(3) e0] Hence, we have,
4
1 x(n) = [ x(0), x(1), x(2), x(3) }
= [4 + 0 + 0 + 0]
4 x(n) = {1, 1, 1, 1}
ge
observe that,
x(0) = 1 IDFT
X(k) = {4, 0, 0, 0} x(n) = {1, 1, 1, 1}
(ii) n = 1
io led
1
3 + j 2k · 1 3.7 Computing DFT by Matrix Method
x(1) =
4 X(k) e
4
ic ow
k=0
We will now learn how to compute the DFT of a
1
+ j 20 · 1 + j 2 · 1
sequence by using the matrix method. This is a much easier
= X (0) e
4 4
n
+ X (1) e
4
bl kn
N
; k = 0, 1, 2, , N – 1
Te
X(k) = x(n) e
x(1) = 1 n=0
=
4
X (0) e 4
+ X (1) e
4
Substituting this is the DFT equation we get,
N–1
x(n) WN
+ j 22 · 2 + j 23 · 2 kn
X(k) = ; k = 0, 1, 2, N – 1 (3.7.1)
+ X (2) e
4
+ X (3) e
4
n=0
1
= [ 4e0 + 0 · ej + 0 ej2 + 0 ej3 ] = 1 Similarly the IDFT which is given by the equation,
4
N–1 + j 2kn
1
x(2) = 1 x(n) =
N X(k) e
N
; n = 0, 1, N–1
k=0
(iv) n = 3
can be written in terms of WN as,
3 + j 2k · 3
1
4 N–1
1
x(3) = X(k) e
–kn
4 x(n) = X(k) WN (3.7.2)
k=0 N
k=0
DSIP (MU-Sem.7-COMP) 3-16 Discrete Fourier Transform (DFT)
x(1) X(1)
x(0) X(0)
where, x(n) =
x(2): ; X(k) =
X(2)
x(N–1) X(N–1)
:
–j 2
N 1 N 1 N
We know WN = e
and
We calculate each value of the matrix,
2
0 –j
4
W4 = e = 1
ge
2
1 –j ·1
4
io led W4 = e = –j
2
2 –j ·2
4
W4 = e = –1
2
3 –j ·3
4
W4 = e = +j
ic ow
2
4 –j ·4
4
W4 = e = +1
n
bl kn
2
6 –j ·6
4
W4 = e = –1
2
at
Pu ch
9 –j ·9
4
W4 = e = –j
1
(3.7.4) 1 1 1 1
Te
nk nk –j –1 j
Each value of WN
matrix is obtained by multiplying n W4 = (1)
1 –1 +1 –1
1
and k. WN is called a N N DFT matrix.
j –1 –j
Note : Changing n and k co-ordinates will not make any
Hence a 4 4 DFT matrix is shown in Equation (1).
difference.
As mentioned earlier, WN is called the Twiddle
Similarly, Equation (3.7.2) can be written as, factor.
1
IDFTx(n) = [WN] X (k) (3.7.5) The word twiddle means "Turn in a twisting or
N
spinning motion”. In other words, to move in a turning
Before we start solving examples of DFT using the
matrix method, let us try to generate WN matrix. (circular) fashion. A lot of us have a habit of twiddling our
tumbs while waiting for an oral exam.
3.7.1 Solved Examples of DFT Now WN is called a twiddle factor because it is cyclic
Ex. 3.7.1 : Generate a 4 4 DFT matrix. in nature.
Soln.: Since we require a 4 4 matrix N = 4. Shown below are W4 values mapped on a circle.
0 4 8
W4 = W4 = W4 = 1
1 5 9
W4 = W4 = W4 = – j
2 6
W4 = W4 = – 1
3 7
W4 = W4 = + j
Fig. P. 3.7.1(a)
Similarly for W8, we can draw the values of the 8 8 matrix using a circle.
ge
io led
ic ow
n
bl kn
at
Pu ch
Fig. P. 3.7.1(b)
Te
2
Let us calculate each of these values and verify 9 –j ·9 9 9
W8 = e 8
= cos – j sin
0 –j
2
·0 4 4
W8 = e 8
= cos 0 – j sin 0 = 1
= 0.707 – 0.707 j
2
1 –j ·1 2
W8 = e 8
= cos – j sin = 0.707 – 0.707 j W8 = e
10 –j
8
· 10
= cos
5
– j sin
5
=–j
4 4 2 2
2
2 –j ·2 2
W8 = e 8
= cos – j sin = – j W8 = e
11 –j
8
· 11
= cos
11
– j sin
11
2 2 4 4
2
3 –j ·3 3 3 = – 0.707 + 0.707 j
W8 = e 8
= cos – j sin = – 0.707 – 0.707 j
4 4 2
12 j · 12
4 –j
2
·4 W8 = e 8
= cos 3 – j sin 3 = – 1
W8 = e 8
= cos – j sin = –1 2
13 j · 13 13 13
–j
2
·5 5 5 W8 = e 8
= cos – j sin
5 4 4
W8 = e 8
= cos – j sin = – 0.707 + 0.707 j
4 4
= – 0.707 + 0.707 j
2
6 –j ·6 3 3 2
W8 = e 8
= cos – j sin = +j 14 j · 14 7 7
2 2 W8 = e 8
= cos – j sin = +j
2 2
2
7 –j ·7 7 7 2
W8 = e 8
= cos – j sin = 0.707 + 0.707 j 15 j · 15 15 15
4 4 W8 = e 8
= cos – j sin
4 4
2
8 –j ·8
W8 = e 8
= cos 2 – j sin 2 = +1 = 0.707 + 0.707 j
2
16 j · 16
W8 = e 8
= cos 4 – j sin 4 = 1
DSIP (MU-Sem.7-COMP) 3-18 Discrete Fourier Transform (DFT)
Using these values we can easily generalize a 8 8 Since W8 is cyclic we have,
DFT matrix.
0 8 16 24
W8 = W8 = W8 = W8 = W8 = W8 = 1
32 40
1 9 17 25 33 41 49
W8 = W8 = W8 = W8 = W8 = W8 = W8
= 0.707 – 0.707 j
2 10 18 26 34 42
W8 = W8 = W8 = W8 = W8 = W8 = j
3 11 19 27 35 43
W8 = W8 = W8 = W8 = W8 = W8
= – 0.707 0.707 j
4 12 20 28 36 44
W8 = W8 = W8 = W8 = W8 = W8 = 1
5 13 21 29 37 45
W8 = W8 = W8 = W8 = W8 = W8
= – 0.707 + 0.707 j
6 14 22 30 38 46
W8 = W8 = W8 = W8 = W8 = W8 = j
ge
7 15 23 31 39 47
and W8 = W8 = W8 = W8 = W8 = W8
= 0.707 + 0.707 j
io led
Using these values we generate a 8 8 DFT matrix.
ic ow
n
bl kn
at
Pu ch
Te
Let us now solve a few examples by using the DFT matrix method.
Ex. 3.7.2 : Compute the DFT of the sequence x(n) = { 1, 1, 1, 1}
Soln.: This is the same sequence which was solved in Ex. 3.4.3.
kn
X(k) = x(n) WN ,
n=0
– j 2kn
nk
Where, WN = e
Since the length of x(n) = 4, the DFT equation reduces to,
3
kn
X(k) = x(n) W4 ; k = 0, 1, 2, 3
n=0
1 1
1 1 1 1 1
Where, x(n) =
1
Step 1 :
1 1
1
W4 x (n)
1
1 1 1 1
1 –j 1
1 1 1 1 1
–j
X(k) =
–1 j Step 2 :
1
1 –1 1 –1 1 1 –j
1 j –1 –j 1
1
1 1 1 1
0
4
–j +j
X(k) =
Step 3 :
1
0 1 –j
0 +j
ge
1
1 1 1 1
Hence, X(k) = [ 4‚ 0‚ 0‚ 0 ]
Step 4 :
–j j
We note the answer is the same as that obtained in
1
io led +1
Example 3.4.3. 1 j –j
Ex. 3.7.3 : Compute the DFT of x(n) = {1, 2, 3, 4}
1
1 1 1 1
ic ow
+j
X(k) = [W4]4 4 x(n)
Ex. 3.7.4 : Compute the IDFT of
at
1 –j –1 2
1 1 1 1 1
Pu ch
X(k) =
j Soln. : The IDFT is given by the equation
1 –1 1 –1 3 N–1
Te
1 j –1 –j 4 x(n) =
1
N X(k) WN
– nk
; n = 0, 1, 2, N – 1
k=0
–2 +2j
10
In matrix form it is written as,
X(k) = 1
*
–2 x(n) = [WN] X(k)
N
– 2 – 2j Since X(k) is of length 4, N = 4 and we generate a IDFT
X(k) = { 10‚ –2 +2j‚ –2‚ – 2 – 2j } matrix of size 4 4.
*
This is the same as obtained in Example 3.5.7. W4 X (k)
1 j –2 + 2j
You must have realized that the matrix method is much 1 1 1 1 10
easier that the conventional method of opening the
x(n) =
1 –1 –j
1 –1 –1 –2
summation. 4 +1
Note : The DFT matrix depends only on the length of x(n) and
not the values of x(n). Because of this for every 4 point
1 –j –1 j –2 – 2j
input, we use the same 4 4 DFT matrix. 4
2
1 Soln. : The IDFT is given by the equation
1
N–1
x(n) =
– nk
3 x(n) =
N
X(k) WN ; n = 0, 1, 2, N – 1
4 k=0
1 –j j 1+j
ge
j –1
X(k) =
1 –1 1 0
4
–1
1 j –1 0 1 4
io led –j x(n) =
1–j
2
4 0
0
ic ow
X(k) =
0 1
1
1+j
n
x(n) =
X(k) = { 2, 1– j, 0, 1 + j} 0
bl kn
Ex. 3.7.7 : For a continuous time signal equation, s(t) = sin [2 1000 t ] + 0.5 sin [ 2 2000 t ] Sample the given signal
at 8000 samples/sec and find out 8 point DFT. Plot magnitude and phase response.
Soln. :
Given :Sampling rate Fs = 8000 sample / sec. Discrete signal is obtained by replacing t by n/Fs
1 1 1 1 1 1 1 1 0
1 (0.707 – j –j (– 0.707 – j –1 (– 0.707 + j j (0.707 + j 0.707) 1.207
0.707) 0.707) 0.707)
1 –j –1 j 1 –j –1 j 1
X(k) = 1 (– 0.707 – j j (0.707 – j 0.707) –1 (0.707 + j 0.707) –j (– 0.707 – j 0.707) 0.207
0.707)
1 –1 1 –1 1 –1 1 –1 0
1 (0.707 + j –j (0.707 + 0.707) –1 (0.707 – j 0.707) j (– 0.707 – j 0.707) – 0.207
0.707)
1 j –1 –j 1 j –1 –j –1
1 (0.707 + j j (– 0.707 + j –1 (– 0.707 – j –j (0.707 – j 0.707) – 1.207
0.707) 0.707) 0.707)
0
ge
0 – j3.99
– 0.3 j
j2
io led
j0.0003
–2j
0.006 j
–j0.0003
= =
0 0
ic ow
0.3 j
2j
j2
n
– 0.006 j
j3.99
bl kn
at
Pu ch
Fig. P. 3.7.7(a)
x (n) = cos
n
Soln. :
4 n = 0, 1, 2, 3
Fig. P. 3.7.7
We substitute values of n
0
x(10) = cos
4 =1
DSIP (MU-Sem.7-COMP) 3-22 Discrete Fourier Transform (DFT)
x(1) = cos We generate a circular matrix of x2 (n)
4 = 0.707
214 3
y (0) 143 2 1
x(2) = cos
2
4=0
y (1)
=
1
x(3) = cos = – 0.707
3 y (2) 3 2 1 4 2
4 y (3) 4321 2
x (n) = {1, 0.707, 0, –0, 707}
y (0) 15
1 –j
1 1 1 1 1
y(n) = {15, 17, 15, 13}
y (k) =
–1 j 0.707
1 –1 –1 Ex. 3.7.10 : Compute the 8-point DFT of the sequence
ge
1 0
1 j –1 –j – 0.707 x(n) = {0, 1, 2, 3}. Also draw the magnitude and phase plot.
Soln. : Since we require a 8-point DFT, we append four
io led
y (k) = {1, 1– j 1.414, 1, 1 + j 1.414} zeros to the original input sequence.
Ex . 3.7.9 : Compute circular convolution of x1 (n) = { 1,1,2,2} x(n) = { 0, 1, 2, 3, 0, 0, 0, 0 }
ic ow
x2 (n)
y (n) = x1 (n) O
at
Pu ch
Te
–1.414 – j 4.83
6
–2 + j2
1.414 – j 0.83
1.414–2+ j 0.83
X(k) =
–2 – j2
– 1.414 + j 4.83
DSIP (MU-Sem.7-COMP) 3-23 Discrete Fourier Transform (DFT)
X(k) ={6, –1.414 – j 4.83, –2 + j2, 1.414 – j 0.83, Ex. 3.7.11 : Determine 2-point and 4-point DFT of a
–2, 1.414 + j 0.83, –2 – j2, – 1.414 + j 4.83} sequence,
Since X(k) is complex, we plot the magnitude and phase. x(n) = u(n)–u(n–2)
|X(k)| = 2
(Real) + (Imaginary) 2 Sketch the magnitude of DFT in both the
|X(k)| = {6, 5.03, 2.83, 1.64, 2, 1.64, 2.83, 5.03} cases.
X(k) = tan–1
Imaginary Soln. :
Real
We begin with Identify the signal
X(k) = {0, – 106.31, 135, –30.4, 0, 30.4,
x (n) = u(n) – u (n –2) is shown in Fig. P.3.7.11.
– 135, 106.31}
We now draw the magnitude and phase spectrum.
ge
io led
ic ow
n
bl kn
Fig. P.3.7.10
at
Pu ch
Te
Fig. P. 3.7.11
x (n) = {1,1}
Since N = 2, we use a 2 2
DFT matrix
–j2
·1 – j
| X (k) | = (Real)2 + (Imaginary)2
W12 = e 2 = e =–1
| X (k) | = {2, 1.414, 0, 1.414}
1 1 The magnitude plot is shown in Fig. P. 3.7.11(b).
Wnk = 1 –1
2
1 11
X (k) = 1 –1 1
Fig. P. 3.7.11(b)
X (k) = 2
0
Ex. 3.7.12 : Compute the DFT of four point sequence
ge
x(n) = {0, 1, 2, 3}
X (k) = {2,0}
Soln. :
| X (k) | =
io led
(Real)2 + (Img)2
The four point DFT in the matrix form is given by,
| X(k) | = 22 = 2
X(k) = [ W4 ] · x ( n )
ic ow
j
n
1 –j –1
bl kn
=
1 –1 1 – 1 2
1 j –1 – j 3
at
Pu ch
0 – j – 2 + 3j – 2j + 2j
0+1+2+3 6
=
Te
We append two zeros to x (n) to get x (n) = {1,1,0,0} Ex. 3.7.13 : Calculate 8 point DFT of
x ( n ) = { 1, 2, 1, 2 }
We have already learnt how to generate a 4 4 DFT
Soln. :
matrix
First we will make length of given sequence ‘8’ by
X (k) = [W4] 4 4 x (n)
appending zeros to x(n).
1
1 1 1 1 1
X (k) =
1 –j –1 j x ( n ) = {1, 2, 1, 2, 0, 0, 0, 0}
1 –1 1 – 1 0
1 j –1 –j 0
Now
X (k) =
0
1+j
DSIP (MU-Sem.7-COMP) 3-25 Discrete Fourier Transform (DFT)
1 1 1 1 1 1 1 1 1
1 –j –1 j 1 –j –1 j 1
1 j –1 –j 1 j –1 –j 0
ge
1 0.707 + j 0.707 j – 0.707 + j 0.707 –1 – 0.707 – j 0.707 –j 0.707– j 0.707 0
io led
1+2+1+2+0+0+0+0
1 + 1.414 – j 1.414 – j – 1.414 – j 1.414 + 0 + 0 + 0 + 0
ic ow
1–j2–1+j2+0+0+0+0
X(k) =
n
1 – 1.414 – j 1.414 + j + 1.414 – j 1.414 + 0 + 0 + 0 + 0
bl kn
1–2+1–2+0+0+0+0
1 – 1.414 + j 1.414 – j + 1.414 + j 1.414 + 0 + 0 + 0 + 0
at
Pu ch
1+j2–1–j2+0+0+0+0
Te
1 – j3.828
6
0
1 – j 1.828 This is the required DFT.
1 + –j 1.828
X(k) =
2
0
1 + j3.828
The 8 point DFT of the sequence is
X (k) ={6,1 – j3.828, 0, 1 – j 1.828, – 2, 1 + j 8. 28, 0, 1 + j 3.828}
Ex. 3.7.14 : Compute 8 point DFT of the sequence x (n) = {0, 1, 2, 3}. Sketch the magnitude and phase plot also
Soln. : Given sequence is, x (n) = {0, 1, 2, 3}
It is asked to calculate 8 point DFT.
We append four zero to x (n) to make its length equal to 8,
x (n) = {0, 1, 2, 3, 0, 0, 0, 0}
DSIP (MU-Sem.7-COMP) 3-26 Discrete Fourier Transform (DFT)
1 1 1 1 1 1 1 1 0
1 –j –1 j 1 –j –1 j 2
X(k) = 1 –1 1 –1 1 –1 1 –1 0
1 j –1 –j 1 j –1 –j 0
ge
–1.414 – j 4.828
6
–2+j2
io led
X (k) =
1.414 – j 0.828
–1.414
ic ow
–2–j2
+ j 0.828
n
– 1.414+ j 4.828
bl kn
at
Pu ch
Imaginary
Phase response = tan –1
Real
The magnitude plot and phase plot are shown in Fig. P. 3.7.14.
Fig. P. 3.7.14
DSIP (MU-Sem.7-COMP) 3-27 Discrete Fourier Transform (DFT)
ge
io led
ic ow
Fig. P. 3.7.14(a)
n
We draw the, magnitude and phase plot
bl kn
1 1 1 1 2 3
Fig. P. 3.8.15
X(k) =
1 –j –1 j 0
=
2+j
1 –1 1 –1 0 1
1 j –1 –j 1 2–j
X(k)= { 3, 2 + j, 1, 2 – j }
Magnitude plot
| X (k ) | = Re2 + Im2
X (k) = tan
–1
Img
Real
Fig. P. 3.7.15(a)
DSIP (MU-Sem.7-COMP) 3-28 Discrete Fourier Transform (DFT)
Ex. 3.7.16 : Compute the sequence x(n) for which the DFT is – 1.4142 – 4.8284i
{20, – 4 + 4j, – 4, – 4 – 4j} – 2.0000 + 2.0000i
Soln. : Since we need to find the sequence x(n), we 1.4142 – 0.8284i
compute the IDFT. – 2.0000 – 0.0000i
The IDFT is given by the equation 1.4142 + 0.8284i
1 *
x(n) = [W4] X(k) – 2.0000 – 2.0000i
N
–1.4142 + 4.8284i
Since N = 4, we use a 4 4 IDFT matrix.
– 4+ 4j
1 1 1 1 20 Ex. 3.7.17 : Find the DFT of following sequence and check
1 1 j –1 –j your result by using IDFT x (n) = {0, 1, 2, 3}
x(n) =
4
1 –1 +1 –1 – 4 Soln. :
1 –j –1 j – 4 – 4j
We have already obtained DFT of x (n) of Ex. 2.7.2
8
ge
1 16 It is X (k) = {6, 2j – 2, – 2, – 2j – 2}
x(n) =
4 24
32
io led
Calculation of IDFT :
x(n) = { 2, 4, 6, 8 } 1
x (n) =
N [ W] X
N N
ic ow
1
sequence of any length. x(0) 1 1 1 1 6
= – j
n
Program to Compute the DFT using Matrix Method x (1) 1 j –1 2j−2
bl kn
clc x (2) 4 1 –1 1 – 1 −2
clear all
x (3) 1 –j –1 j −2j−2
at
Pu ch
1
x={0 1 2 3 0 0 0 0] ; 6 + 2j – 2 – 2 – 2j – 2 0 0
N=length (x); 1 6 – 2 – 2j + 2 – 2 + 2j = 4 = 1
Te
=
4
6 – 2j + 2 – 2 + 2j + 2 4 8 2
for k = 0 : 1 : N–1 6 + 2 + 2j + 2 + 2 – 2j 12 3
for n = 0 : 1 : N–1
x (n) = {0, 1, 2, 3}
W (n+1, k+1) =exp (–j*2*pi*k*n/N);
end Ex. 3.7.18 : Show that the basis matrix for DFT is unitary.
end
Consider N = 4.
X=W*x'
X_Mag=abs (X); Soln. : A matrix is said to be unitary is
W4 =
1 –j –1 j
X=
1 –1 1 – 1
6.0000 + 0.0000i 1 j –1 – j
DSIP (MU-Sem.7-COMP) 3-29 Discrete Fourier Transform (DFT)
3.8.1 Linearity
1 1 1 1
and W =
1 j –1 – j
MU - Dec. 2015, Dec. 2017, May 2018)
4 1 –1 1 – 1
1 –j –1 j Q. State the DFT Properties : Linearity.
(Dec. 2015, Dec. 2017, May 2018, 2 Marks)
Now
1 1 1 1 DFT
x1(n) X1(k)
j
If and
1 –j –1
W4 W4
T
= DFT
1 –1 1 – 1 x2(n) X2(k) then
1 j –1 – j DFT
a x1(n) + bx2 (n) a X1(k) + bX2(k)
1 1 1 1
1 j –1
–j Proof : According to the definition of DFT,
–1
ge
N–1 – j2nk
1 –1 1
1 –j –1 j X(k) = x(n) e N
n=0
io led
1 0 0 0 Let x(n) = ax1(n) + bx2(n)
4 =
0 1 0 0 4 [I]
N–1 – j2nk
0
ic ow
n=0
0 0 1
N–1 – j2nk N–1 – j2nk
n
Hence DFT matrix is unitary = a x1(n) e N
+ bx2(n) e N
bl kn
n=0 n=0
3.8 Discrete Fourier Transform (DFT) N–1 – j2nk N–1 – j2nk
at
Properties N
N
Pu ch
= a x1 (n) e +b x2 (n) e
n=0 n=0
MU - May 2016, Dec. 2016, May 2017 = a X1 (k) + b X2 (k)
Te
Hence
Q. State any five DFT properties.
DFT
(May 2016, Dec. 2016, May 2017, 10 Marks) If x1(n) X1 (k)
DFT
Like any other transform, the DFT has several important and x2(n) X2(k), then
properties. These properties help us in computing the DFT DFT
easily. ax1(n) + bx2(n) aX1(k) + bX2(k)
The properties that we study here are listed below. Solved Example
1. Linearity 2. Periodicity
Ex. 3.8.1 : x1 (n) = {1, 2, 3, 4} and x2 (n) = {5, 6, 7, 8}
3. Circular time shift 4. Circular frequency shift
Compute the DFT of the sequence
5. Time reversal 6. Symmetry property x3 (n) = 2x1 (n) + 3x2 (n)
7. Complex Conjugate property Soln. : From the Linearity property we know
8. Parseval's theorem DFT
If x1 (n) X1 (k)
9. Multiplication
DFT
10. Circular Convolution property x2 (n) X2 (k)
Though the Proof of each of the properties is not a DFT
part the syllabus, we shall prove them for the sake of then, a x1 (n) + bx2 (n) aX1 (k) + bX2 (k)
continuity. Students can choose to ignore them. Now, x3 (n) = 2x1 (n) + 3x2 (n)
We will also solve examples using them. DFT { x3 (n)} = DFT { a x1 (n)} + DFT {b x2 (n) }
DSIP (MU-Sem.7-COMP) 3-30 Discrete Fourier Transform (DFT)
DFT
is x3 (n) aX1 (k) + bX2 (k) Proof : According to the definition of the DFT
N–1 – j2nk
We calculate DFT of x1 (n) and x2 (n)
X(k) = x(n) e N
1 –j –1 2
1 1 1 1 1
n=0
X1 (k) =
j We replace k by (k + N)
1 –1 1 –1 3 – j2n(k + N)
1 j –1 4
N–1
–j X(k + N) = x(n) e N
–2 + 2j
10 n=0
N–1 – j2nk – j2nN
X1 (k) =
–2 = x(n) e N
e N
–2 –2j n=0
N–1 – j2nk
1 –j –1 6
1 1 1 1 5
= x(n) e N
e – j2n
j n=0
ge
Similarly X2(k) =
1 –1 1 –1 7 Now, e – j2n
= cos 2n – jsin 2n = 1
1 j –1 io led –j 8 N–1 – j2nk
N
–2 +2j
26 X(k + N) = x(n) e
X2 (k) =
n=0
–2 = X(k)
–2 –2j
ic ow
X(k + N) = X(k)
DFT {x3 (n)} = X3 (k) = 2 X1 (k) + 3X2 (k) Hence the DFT is periodic with period N.
n
bl kn
–2 + 2j –2 +2j
10 26 Circular shift of a sequence :
= 2
+3 Before we move to the next properties, let us
at
–2 –2
Pu ch
=
+
–4 –6
–4 –4j –6 –6j
–10 + 10 j
98
X3 (k) =
–10
–10 –10j
X3 (k) = {98, –10 + 10 j, –10, –10 –10j} Fig. 3.8.1(a)
3.8.2 Periodicity A periodic extension of a sequence x(n) can be written
MU - Dec. 2015, Dec. 2017, May 2018) as,
+
Q. State the DFT Properties : Periodicity. xp(n) = x(n – lN); where N is the period.
l = –
(Dec. 2015, Dec. 2017, May 2018, 2 Marks)
This is shown in Fig. 3.8.1 (b).
A simple way of visualizing a periodic signal is to
DFT
If x(n) X(k) imagine x(n) on a circle in the counter clockwise direction.
then X(k + N) = X(k) The Fig. 3.8.1(b) will make this clear.
i.e., The DFT is periodic with a period N. xp (n) = X((n))N is the periodic extension of x(n).
DSIP (MU-Sem.7-COMP) 3-31 Discrete Fourier Transform (DFT)
Fig. 3.8.1(e)
Fig. 3.8.1(b)
Here ((n))N denotes n modulo N.
As stated earlier, the periodic signal xp (n) can be
x((n – 2))N denotes x(2 modulo N)
viewed as lying on a circle in the counter-clockwise
A general way of representing a periodic signal is,
direction.
ge
xp (n) = x [(n modulo N)] or x((n))N.
io led If n is between 0 and N – 1, then leave it as it is. If not,
then add or subtract multiplies of N from n until the result
is between 0 and N – 1.
Example : x(– 3 Modulo 4) = x((–3))4 = x(1)
ic ow
be written as,
Fig. 3.8.1(c)
+
at
xp (n) = x [(n modulo N)] = xp ((n))N x(n) = {x(0), x(1), x(2), , x(N – 1)}
If we now shift the periodic signal by say 2. then x((n – 1)N = {x(N – 1), x(0), x(1), , x(N – 2)}
We get, x((n – 2))N = {x(N – 2), x(N – 1), x(0), x(1), , x(N – 3)}
: :
: :
: :
x((n – N))N = {x(0), x(1), , x(N – 1)}
x((n – N))N = x(n)
In a similar way,
x((n – m))N = x(N – m + n)
ge
x2(n) = {3, 4, 1, 2}
Since, x((n – m))N = x(N – m + n), we have
m–1 – j2nk m–1 – j2nk Soln. :
io led
x((n – m))N e N
= x(N – m + n) e N (i) We first find the DFT of x(n) using the matrix notation
n=0 n=0 nk
X = WN x
Let N – m + n = l
ic ow
X(0) 1 1 1 1 x(0)
j x(1)
n = l–N+m
X(1) 1 –j –1
n
– j2nk N–1 – j2k(N + m + l) =
X(2) 1 –1 1 – 1 x(2)
bl kn
– j x(3)
N N
x((n – m))N e = x(l) e
l= N–m X(3) 1 j –1
X(0) 1 1 1 1 1
at
Pu ch
N–1 – j2k(l + m)
= x(l) e N
e+ j2k X(1) =
1 –j –1 j 2
l= N–m X(2) 1 –1 1 –1 3
–j 4
Te
X(3) 1 j –1
Since e+ j2k = 1 for k = 0, 1, 2, …. we have,
X(k) = {10, – 2 + 2j, – 2, – 2 –2j}
– j2nk N–1 – j2k(l + m)
(ii) We now assume that x(n) is periodic, we plot x(n)
x((n – m))N e N
= x(l) e N
l= N–m
…(3.8.2)
Similarly for the second part of Equation (3.8.1) we
have,
N–1 – j2nk N–1–m – j2k(m + l)
x((n – m))N e N
= x(l) e N
n=m l=0
…(3.8.3)
Substituting Equations (3.8.2) and (3.8.3) in
Equation (3.8.1) we get,
N–1 – j2k(l + m)
Fig. P. 3.8.2
DFT {x((n – m))N} = x(l) e N
Fig. P. 3.8.2(b)
ge
We know DFT 2k
DFT x (n + 2) W4 X (k)
If x(n) X(k)
io led 2k
– j2pk
X2(k) = W4 X(k)
DFT N 0
x(n – p) e X(k) X2(0) = W4 X(k) = (1) (10) = 10
ic ow
DFT pk 2
i.e., x(n – p) WN X (k) X2(1) = W4 X (k) = (– 1) (– 2 + 2j) = 2 – 2j
4
n
DFT k X2(2) = W4 X (k) = (1) (– 2) = –2
x(n – 1) WN X(k)
bl kn
6
DFT k X2(3) = W4 X (k) = (– 1) (– 2 – 2j) = 2 + 2j
x1(n) = x(n – 1) WN X(k)
at
We already know X(k) = {10, – 2 + 2j, – 2, – 2 – 2j} X2(k) = {10, 2 – 2j, –2, 2 + 2j}
k
i.e., X1(k) = W4 X (k)
Te
Ex. 3.8.3 :
0
X1(0) = W4 X (0) = (1) (10)
(i) x (n) = {1, 2, 3, 4} find DFT X (k)
= 10 (ii) Using results obtained in part (i) and not otherwise find
1
X1(1) = W4 X (1) = (– j) (– 2 + 2j) = 2 + j2 the DFT of following sequences
2 x1 (n) = {4, 1, 2, 3} x2 (n) = {2, 3, 4, 1}
X1(2) = W4 X (2) = (– 1) (– 2) = 2
3 x3 (n) = {3, 4, 1, 2} x4 (n) = {4, 6, 4, 6}
X1(3) = W4 X (3) = (j) (– 2 – 2j) = 2 – j2
Soln. :
DFT {4, 1, 2, 3} = {10, 2 + j2, 2, 2 – j2}
X (1)
X (0) 1 1 1 1 1
j
X1(k) = {10, 2 + j2, 2, 2 – j2}
1 –j –1 2
(i) =
Similarly for x2(n), we observe that x2(n) is simply x(n)
X (2) 1 –1 1 – 1 3
shifted to the left by 2 or to the right by 2. X (3) 1 j –1 – j 4
x2(n) = x(n + 2) = x (n – 2)
1 – 2j – 3 + 4j
1+2+3+4 10
Let us take x2(n) = x (n + 2)
=
= – 2 + 2j
(Both will give the same answer) 1 – 2 + 3 – 4 –2
1 + 2j – 3 – 4j – 2 – 2j
X (k) = {10, – 2 + 2j, – 2, – 2, – 2j}
DSIP (MU-Sem.7-COMP) 3-34 Discrete Fourier Transform (DFT)
(ii) (a) Given x1 (n) = {4, 1, 2, 3} and – j2
ge
k=1 X1 (1) = X (1) e 4
= (– 2 – 2j) cos + j sin
6 6
= (– 2 + 2j) cos – j sin
2 2
4 4
4
io led 4
X2 (3) = (– 2 – 2j) [– j]
X1 (1) = (– 2 + 2j) (– j)
X2 (3) = – 2 +2j
X1 (1) = 2 + j2
ic ow
For k = 2 X1 (2) = X (2) e 4 = X (2) e– j (c) Given x3 (n) = {3, 4, 1, 2} and x (n) = {1, 2, 3, 4}.
n
That means x3 (n) is obtained by delaying x (n) by 2
X1 (2) = (– 2) [cos – j sin ]
bl kn
positions.
= (– 2) (– 1)
x3 (n) = x (n – 2)
at
Pu ch
X1 (2) = 2
– j6 According to circular time shifting property,
4 – j2kl
For k = 3
Te
(b) Given x2 (n) = {2, 3, 4, 1} and x (n) = {1, 2, 3, 4}. For k = 1 X3 (1) = X (1) e–j = (– 2 + 2j) [cos – j sin ]
Thus x2 (n) is obtained by advancing x (n) by X3 (1) = (– 2 + 2j) (– 1)
position X3 (1) = 2 – 2j
x2 (n) = x (n + 1) For k = 2 X3 (2) = X (2)e– j2
According to circular time shifting property, = (– 2) [ cos 2 – j sin 2 ]
DFT
– j2kl X3 (2) = (– 2) (1)
x (n – l) – X (k) e N X3 (2) = – 2
– j2k
DFT For k = 3 X3 (3) = X (3) e– j3
x (n + 1) – X (k) e N
– j2k
= (– 2 – j2) [ cos 3 – j sin 3 ]
X3 (3) = (– 2 – j2) [– 1]
X2 (k) = X (k) e N
X3 (3) = 2 + j2
For k = 0 X2 (0) = X (0) e = 10
X3 (k) = {10, 2 – j2, – 2, 2 + j2}
DSIP (MU-Sem.7-COMP) 3-35 Discrete Fourier Transform (DFT)
X4 (0) = 20
ge
X4 (1) = 0 io led
For k = 2 X4 (2) = X (2) + (– 1)2 X (2) = – 2 + (– 2)
X4 (2) = – 4
ic ow
Fig. P. 3.8.4
X4 (k) = {20, 0, – 4, 0}
at
Pu ch
1 1 1 1 2 Here l = 3, N = 4
=
1 –j –1 j 0 and X (k) = {3, 2 + j, 1, 2 – j}
1 –1 1 –1 0
1 j –1 –j 1 So, DFT of x (n) is,
2+0+0+1 3
k = 0 X (0) e– j0 = 3
=
2+0+0+j = 2+j
2+0+0–1 1 – j2 1 3 – j3
ge
k = 0, 1, 2, 3
io led – j23k – j3k
That means phase angle is e 4 = e 2
Due to this added phase angle DFT will be same as
DFTOF (ii). Fig. P. 3.8.5(a)
ic ow
4 k
–
5
Y (k) = e X(k)
Te
Fig. P. 3.8.5(b)
Ex. 3.8.6 :
1 0n3
x [n] =
0 4n7
Fig. P. 3.8.5 (i) Find DFT X [ k ]
(ii) Using the result obtained in (i) find the DFT of the
Soln. : The given sequence contains 5 points. It can be
following sequences.
written as, n=0
1
x1 [n] = 0 1n4
x (n) = {1 , 2, 2, 1, 0 } 1 5n7
0 0n1
and x2 [n] = 1 2n5
According to circular time shifting property, 0 6n7
DFT Soln. :
kl
x ((n – l))N X (k) WN
N 1 0 n 3
(i) Given, x(n) =
0 4 n 7
– j2
We have WN = e N Here N = 5 x(n) = {1, 1, 1, 1, 0, 0, 0, 0}
DSIP (MU-Sem.7-COMP) 3-37 Discrete Fourier Transform (DFT)
1 –j –1 j 1 –j –1 j 1
X(k) =
1 – 0.707 – j 0.707 j 0.707 – j 0.707 – 1 0.707 + j 0.707 – j – 0.707 + j 0.707 1
11 – 0.707–+1j 0.707 –1j 0.707 –+ 1j 0.707 –11 0.707 –– 1j 0.707 1j – 0.707–– 1j 0.707 11
1 1
1 0.707 + j 0.707 j – 0.707 + j 0.707 – 1 – 0.707 – j 0.707 – j 0.707– j 0.707 1
j –1 –j 1 j –1 –j
ge
1–j–1+j+0+0+0+0
X(k) =
1 – 0.707 – j0.707 + j + 0.707 – j0.707 + 0 + 0 + 0 + 0
io led
1–1+1–1+0+0+0+0
1 – 0.707 + j0.707 – j + 0.707 + j0.707
1+j–1–j+0+0+0+0
n
bl kn
20
Pu ch
1 n = 0 – j10
8
2 –j
8 X(2) = 0
(ii) Given x1(n) = 0 1 n 4 X1(2) = e X(2) = e
1 5 n 7 10 30
3
Te
–j –j
X1(3) = e 8 X(3) = e 8 X(3)
x1(n) = {1, 0, 0, 0, 0, 1, 1, 1}
Comparing with x(n), we can write = (0.707 + j0.707) (1 – j0.414) = 1 + j0.414
10
x1(n) = x ((n – 5)) –j 4
X1(4) = e 8 X(4) = 0
According to circular time shifting property,
10
DFT –j 5
kl X1(5) = e 8 X(5)
x1 ((n – 1)) X(k) WN
N = (0.707 – j0.707) (1 + j0.414) = 1 – j0.414
DFT 10
x1(n) = x((n – 5)) X(k) WN
k.5 –j 6
X1(6) = e 8 X(6) = 0
N
10
– j2k –j 7
k X1(7) = e 8 X(7)
Now WN = e N
– j70
– j2
5k 5k = e 8 (1 + j2.414) = 1 – j 2.41
WN = e 8
X1(k) = {4, 2.41 – j, 0, 1 + j0.414, 0,
– j 10 k
= e = – 0.707 + j0.707
8 1 – j0.414, 0, 2.41 + j}
X1(0) = e X(0) = 4
0
0 0 n 1
10 Given x2(n) = 1 2 n 5
X1(1) = e
–j
8 X(1) 0 6 n 7
= (– 0.707 + j0.707) (1 – j2.414) = 1 + j 2.41
DSIP (MU-Sem.7-COMP) 3-38 Discrete Fourier Transform (DFT)
– j2n(N + k – m)
x2(n) = {0, 0, 1, 1, 1, 1, 0, 0} N–1
n=0
Using circular time shifting property = X (N + k – m)
DFT
– kl = X ((k – m))N
x2(n) = x((n + 2)) X(k) WN
N DFT {x(n) e+ j2mn/N} = X ((k – m))N
– 2k
X2(k) = X(k) W8 This is the circular frequency shift property.
– j2.2k – jk
2k Solved Example
Now W8 = e 8 =e z
jk Ex. 3.8.7 : Given signal x(n) = {2, 2, 1, 4} has a 4-point DFT
–
X2(k) = X(k) e 2 X(k). Without performing DFT or IDFT, find out the sequence
x1(n) which would have a 4 point DFT X(k – 1).
X2(0) = x(0) e0 = 4
ge
j Soln. : This is what the problem states
–
X2(1) = x(1) e 2 = (1 – j2.414) (0 + j1) DFT
x(n) X(k)
io led
= – 2.414 – j then
j
X2(2) = X(2) e = 0 DFT
?? X (k – 1)
ic ow
j3
X2(3) = X(3) e 2 = (1 – j0.414) (0 – j) = 0.414 + j The output in the frequency domain is shifted. Hence we
j2 use the circular frequency shift property.
n
X2(4) = X(4) e =0
DFT
bl kn
j3 N
X(k – m)
Pu ch
j2n
N DFT
X2(k) = {4, –2.414 – j, 0, 0.414 x(n) e X(k – 1)
j2n
+ j, 0, 0.414 – j, 0 – 2.414 + j}
x1(n) = x(n) e 4
3.8.4 Circular Frequency Shift j20
= x(n) e N
n=0
DSIP (MU-Sem.7-COMP) 3-39 Discrete Fourier Transform (DFT)
ge
N–1 – j2nk
n=0
io led
x^ (n) = x ((n – 2)) N–1 – j2nk
According to circular time shifting property, DFT {x (N – n)} = x(N – n) e N
DFT
n=0
ic ow
kl
x ((n – l))N X (k) WN
N Let, N–n = m n=N–m
jk(N m)
n
Here, N = 4 and l = 2 N–1
N
bl kn
– j2k N
Pu ch
N–1 j2km
– j2 ╱
N N
but, WN = e N = x(m) e e
m=0
Te
– j2 – j
but,
W4 = e 4 =e 2
N–1 jkm
Let,
^
DFT of x^ (n) = X (k) = x(m) e N
– j m=0
^ 2k 2k
X (k) = X (k) W4 = X (k) e 2 – j2mN – j2mN
N N
^ We now insert e since e
X (k) = X (k) e
– jk
We get,
Given, X (k) = {10, – 2 + 2j, – 2, – 2 – 2j}
N–1 – j2km – j2mN
^
0
for k = 0 X (0) = X (0) e = X (0) = 10 DFT {x(N – m)} = x(m) e N
e N
^ – j m=0
for k = 1 X (1) = X (1) e
– j2m(N k)
= (– 2 + 2j) (cos – jsin )
= x(m) e N
= (– 2 + 2j) (– 1) = 2 – 2j
Comparing this with the standard DFT equation, we
^ – j2
for k = 2 X (2) = X (2) e have
= – 2 (cos 2 – jsin 2) = – 2 DFT
^ – j3
{x (N – m)} X(N – k)
and for k = 3 X (3) = X (3) e
DFT
= (– 2 – 2j) (cos 3 – jsin 3) OR x((– m))N X(N – k)
= (– 2 – 2j) (– 1) = 2 + 2j DFT
x((– n))N X((– k) N
^
X (k) = {10, 2 – 2j, – 2, 2 + 2j}
DSIP (MU-Sem.7-COMP) 3-40 Discrete Fourier Transform (DFT)
ge
1 –1 1 –1 X (k) =
X(3) 1 j –1 –j 4 n=0
N N
2 kn 2 kn
+ j xI (n) · cos
X(k) = {10, – 2 + 2j, – 2, – 2 –2j}
io led 2
(ii) Here x1(n) = {1, 4, 3, 2} N – j xI (n) sin N
Here j2 = – 1; and writing summation for real and
On careful observation, we note that
ic ow
DFT n=0
then x(– n) X (– k) N–1
2 kn 2 kn
∑ xR (n) sin
at
–j
N – xI (n) cos N
X(k) = {10, – 2 + 2j, – 2, – 2 – 2j} n=0
X(– k) = {10, – 2 – 2j, – 2, – 2 + 2j} …(3.8.8)
Te
DFT {x1(n)} = {10, – 2 – 2j, – 2, – 2 + 2j} Comparing Equations (3.8.8) and (3.8.5) we can write,
N–1
3.8.6 Symmetry Property 2 kn 2 kn
XR (k) = ∑ xR (n) cos
N + xI (n) sin n
The symmetry properties of DFT are derived in the n=0
similar way of DTFT symmetry properties. We know …(3.8.9)
that DFT of sequence x (n) is denoted by X (k).
and
Now if x (n) and X (k) are complex valued sequence N–1
then it can be represented as follows : XI (k) = – ∑ xR (n) sin 2 kn – xI (n) cos 2 kn
N N
x (n) = xR (n) + j x I (n), 0 ≤ n ≤ N – 1 …(3.8.4) n=0
ge
XR (n) =
Replacing k by N – k, N N
n=0
N–1
Case (iii) : When x (n) is real and odd
X (N – k) = ∑ x (n) W N
(N – k) n
io led
n=0 Statement : When x (n) is real and odd which means,
N–1 x (n) = – x (N – n) then the DFT becomes,
X (N – k) = ∑ x (n) W N W N
Nn – kn
ic ow
…(3.8.14) N–1
n=0 X (k) = – j ∑ xR (n) sin 2 kn
j2 N
n
– N n=0
bl kn
Now we have, twiddle factor WN = e Proof : Since x (n) is real, we will put xI (n) = 0 in
j2
Nn
Equation (3.8.8). Similarly x (n) is odd and ‘cos’ is even
–
at
= e
Nn
2 kn
N
W N
function so we can write, cos N = 0. Thus first
Pu ch
= e– j 2 n = cos 2n – j sin 2 n
summation in Equation (3.8.8) becomes zero. In the second
Te
Since n is an integer, cos 2 n = 1 and sin 2 n = 0 summation of Equation (3.8.8), putting xI (n) = 0 we get,
Nn N–1
W N 2 kn
xR (n) sin
= 1
X (k) = – j ∑ N
Thus Equation (3.8.14) becomes, n=0
Now using Equation (3.8.13) we can write, When x (n) is purely imaginary which means xR (n) = 0
N–1 and x (n) = j xI (n) then putting xR (n) = 0 in Equation (3.8.9)
X (k) = ∑ x (n) W N
– kn
* …(3.8.17) we get,
n=0 N–1
Thus, from Equations (3.8.16) and (3.8.17) we get, XR (k) = ∑ xI (n) sin 2 kn
N
n=0
X (N – k) = X (– k) = X* (k)
And putting xR (n) = 0 in Equation (3.8.10) we get,
N–1
2 kn
XI (k) = ∑ xI (n) cos
N
n=0
DSIP (MU-Sem.7-COMP) 3-42 Discrete Fourier Transform (DFT)
Symmetry properties can be summarized as shown in Fig. 3.8.2.
Table 3.8.1
ge
N point sequence x [ n ] 0 ≤ n ≤ N – 1
io led N point DFT
x* [n] X* [N – k]
x* [N – n] X* [k]
ic ow
1
xR [n] Xce [k] =
2
[ X [ k ] + X* [ N – k ] ]
n
1
[X [ k ] – X* [ N – k ] ]
bl kn
2
1
xco [n] = [x [ n ] + x*[ N – n ] ] j XI [k]
Te
Ex. 3.8.11 : The first five DFT points of real and even Ex. 3.8.13 : For a 8-point DFT, the first five DFT coefficients
sequence x(n) of length eight are given below. Find are X(k) = X { 10, 2 + 3j, 1 + 2j, j, 4} Find the remaining
remaining three points. coefficients.
X ( k ) = {5, 1, 0, 2, 3, …} Soln. :
Given :
Soln. : Given DFT points are :
X(0) = 10, X(1) = 2 + 3j, X(2) = 1 + 2j,
X ( 0 ) = 5, X ( 1 ) = 1, X ( 2 ) = 0,
X(3) = j, X(4) = 4
X ( 3 ) = 2 and X ( 4 ) = 3. We know, X(k) = X* (N – k)
X(5) = X* (8 – 5) = X*(3) = + j
X* ( k ) = X ( N – k )
X(6) = X*(8 – 6) = X*(2) = 1 – 2j
ge
X ( k ) = X* ( N – k )
X(7) = X* (8 – 7) = X*(1) = 2 – 3j
This is 8 point DFT. Thus N = 8 Therefore the entire DFT sequence is,
io led
X ( k ) = X* ( 8 – k ) X(k) = {10, 2 + 3j, 1 + 2j, j, 4, j, 1 – 2j, 2 – 3j}
Note : The magnitude of the DFT is symmetric about the N/2
ic ow
Ex. 3.8.14 : The first five points of the 8-point DFT of a real
X ( 6 ) = X* ( 8 – 6 ) = X * ( 2 ) valued sequence are,
at
Pu ch
X1 (k) =
–j –1 j X(k) = X* (8 – k)
1 –1 1 –1 4 X(5) = X* (8 – 5) = X* (3)
1 j –1 –j 2
X(6) = X* (8 – 6) = X* (2)
1+2+4+2 9
X1 (k) = 1 – 2 + 4 – 2 = 1
1 – 2j – 4 + 2j –3 X(7) = X* (8 – 7) = X* (1)
1 + 2j – 4 – 2j – 3 X(5) = 1.2 + j0.13
X (1) 1 – j – 1 j 1 + 3j
X (0) 1 1 1 1 1 + 2j X (k) – X* (– k)
(b) X2 (k) =
=
2j
ge
= X (1) – X* (– 1)
1 + 2j – 1 – 3j + 2 + 4j – 2 – 2j X2 (1) =
2j
1 + 2j + j – 3 – 2 – 4j – 2j + 2
io led – j + 2 – j3 2 – j4
= =
2j 2j
–j
6 + 11j
j 2 – j4 2j + 4
= = =–2–j
ic ow
= j 2j –2
+j
– 2 – 3j X2 (2) =
X (2) – X* (– 2) j + j
= =1
n
2j 2j
bl kn
= = =–2+j
x* (n) = x1 (n) – j x2 (n) 2j j 2j
x (n) + x* (n) = 2 x1 (n) X2 (k) = { X2 (0), X2 (1), X2 (2), X3 (3)}
Te
N=0
X* (k) = {6 – 11j, + j, – j, – 2 + j3} N–1 – j2nk
n=0
X (0) + X* (0)
Hence, X1 (0) = N–1
2
6 + 11j + 6 – 11j
= [x(n) ej2nk/N]*
= =6 n=0
2 N–1
X1 (1) =
X (1)+ X* (– 1) = [x(n) e– j2n(N – k)/N]*
2 n=0
– j – 2 + j3 = X*(N – k)
= =–1+j DFT [x*(n)] = X*(N – k) = X*((– k))N
2
DSIP (MU-Sem.7-COMP) 3-45 Discrete Fourier Transform (DFT)
3.8.8 Parseval's Theorem 1
= { 100 + 4 + 0 + 4 }
4
DFT
If x(n) X(k) E = 27
Then Energy of the signal is,
N–1 N–1
Ex. 3.8.17 : Verify Parseval’s Theorem for sequence,
n
E = |x(n)|2
n=0
=
1
N
k=0
X(k)2 ()
x (n) = 2
1
u (n)
Proof : Energy of a signal is given by the equation, Soln. : According to Parseval’s Theorem,
N–1
N–1 N–1
E = |x(n)|2 (3.8.18) | x (n) |
2
=
1
N | X (k) |
2
…(1)
n=0
n=0 k=0
N–1
ge
From the IDFT equation we have, Consider value of N = 4. That means n = 0 to N – 1
N–1
X(k) WN
1 +nK
Let, n = 0 to 3
x(n) =
N
io led
k=0
N–1 Thus sequence x (n) is generated as follows,
1
X
+nK
x (n) = (k) WN (3.8.20) 0
N 1
ic ow
For n = 0 x (0) =
k=0
2 =1
We substitute Equation (3.8.20) in Equation (3.8.19) 1
x (1) =
1 1
n
n = 1 =
N-1
1
W–1
2 2
bl kn
x(n) N
+nk
E = X* (k) WN 2
x (2) =
1 1
n =2 =
k=0 n=0
2 4
at
Pu ch
N 1 1 1 1
k=0 k = 0 x (n) =
N-1
2 4 8
1
E = X*(k) · X(k) Step II : Consider L.H.S. of Equation (1).
N
k=0
N–1 3
1
E =
N
X(k) 2 (3.8.21) L.H.S = 2
| x (n) | = | x (n) |
2
n=0 n=0
We have,
N-1 N-1 2 2 2 2
L.H.S = |x (0)| + |x (1)| + |x (2)| + | x (3)|
1
E = x(n) = 2
X(k) 2
N 1 2 1 2 1 2
n=0 k=0 L.H.S = 1 +
2 +4 +8
Solved Example
L.H.S = 1.328125 …(2)
Ex. 3.8.16 : X(k) = {10, –2, 0, 2}.
Compute the energy of the signal x(n). Step III : Consider R.H.S term,
Soln. : From Parseval's Energy theorem, we have, N–1
1
N–1 N–1 2
R.H.S = | X (k) |
1 N
E = x(n) =
2
X(k) 2
n=0
N
n=0 k=0
1 First we will calculate DFT X (k) using matrix method.
E = { X (0) 2 + X (1) 2 + X (2) 2 + X (3) 2}
4
X (k) = [W4] XN
DSIP (MU-Sem.7-COMP) 3-46 Discrete Fourier Transform (DFT)
1 2 2 2
1 = 1 + (2) + (3) + (4)
1 –j –1 j
X (0) 1 1 1 1 2
X (2) = 1 – 1 1 – 1
X (1) = 1 + 4 + 9 + 16 = 30
1
1 j – 1 – j
4
X (3)
Step II : First we will calculate DFT of x (n) that is X (k)
1
8
X (k) = [W4] xN
X (k)
= {1.875, 0.75 – j0.375, 0.625, 1 1 1 1 1
0.75 + j0.375}
X (k) =
1 –j –1 j 2
1 –1 1 –1 3
Now are will calculate | X (k) |. 1 j –1 –j 4
| X (k) | = {1.875 0.838525, 0.625 0.838525}
10
=
– 2 + 2j
ge
Step IV :
–2
1
N–1 – 2 – 2j
R.H.S = | X (k) |
2
N
io led
k=0 X (k) = {10, – 2 + 2j, – 2, – 2 – 2j}
3
1 Step III :
R.H.S = | X (k) |
2
ic ow
4
k=0 N–1
1
1 R.H.S. = | X (k) |
2
n
2 2 2
R.H.S = { | X (0) | + | X (1) | + | X (2) | + N
4 k=0
bl kn
2
| X (3) | }
Now | X (k) | = {10, 2.828, 2, 2.828}
R.H.S = 1.328125
at
Pu ch
Given : 1
= [100 + 7.997584 + 4 + 7.997584]
4
x (n) = {1, 2, 3, 4}
R.H.S. = 30
According to parseval’s theorem,
N–1 N–1 Step IV : Since L.H.S. = R.H.S, Parseval’s theorem is
1
2
| x (n) | =
N | X (k) |
2
verified.
n=0 k=0
3.8.9 Multiplication of Two Sequences
Step I :
DFT
If x1(n) X1(k)
Here N = 4
DFT
3 and x2(n) X2(k)
L.H.S. = | x (n) |
2 DFT 1
then x1 (n) x2(n) [X1(k) ⊛ X2 (k)]
n=0 N
2 2 2 2
= | x (0) | + | x (1) | + | x (2) | + | x (3) |
DSIP (MU-Sem.7-COMP) 3-47 Discrete Fourier Transform (DFT)
3.8.10 Circular Convolution Property Given two periodic sequences x1(n) and x2(n), circular
convolution can be found out using the following two
MU - Dec. 2015, Dec. 2017, May 2018)
techniques.
Q. State the DFT Properties : Convolution . 1. Concentric circle method
(Dec. 2015, Dec. 2017, May 2018, 2 Marks) 2. Matrix multiplication method
DFT
If x1 (n) X1 (k)
We shall explain each one in detail.
DFT
and x2 (n) X2 (k) 3.9.1 Concentric Circle Method
DFT
x2 (n) X1 (k) · X2 (k).
then, x1 (n) O Given two periodic sequences x1(n) and x2(n)
X3 (k) = X1 (k) X2 (k) y(n) = x1(n) ⊛ x2(n)
is the symbol used for circular convolution.
Hence, (O) Step 1 : Plot the samples of x1(n) evenly around the
We find x3 (n) for which DFT is X3 (k). Some books also outer circle in the counter clockwise direction.
ge
use the symbol N to denote circular convolution. Step 2 : Plot the samples of x2(n) evenly around the
inner circle in the clockwise. Make sure the
Proof : From the Periodic convolution we know, positions of x1(0) and x2(0) coincide.
N–1
io led
x1p (m) x2p
Step 3 : Multiply all the corresponding samples of x1(n)
x3p (n) = (n – m)
and x2(n) and add. This will give us y1(0).
m=0
ic ow
The subscript p stands for periodic. Step 4 : Rotate the inner circle in the direction of the
N–1 outer circle (counter clockwise) by one step and
n
i.e., x3 ((n))N = x1 ((m))N x2 ((n – m))N
repeat step 3.
bl kn
m=0 Step 5 : Repeat step 4 till x1(0) and x2(0) again coincide.
for 0 n N – 1 (one period) We shall take an example to understand these steps.
at
Pu ch
x3 ((n))N = x3 (n),
3.9.1(A) Solved Example on Concentric
x1 ((m))N = x1 (m) Circle Method
Te
N–1
x3 (n) = x1 (m) x2 ((n – m))N (3.8.22) Ex. 3.9.1 : Perform circular convolution on the given two
periodic sequences.
m=0
Now equation RHS of Equation (3.8.22), represents x1(n) = {1, 2, 3, 4}, x2(n) = {4, 1, 1, 2}
circular convolution of x1 (n) and x2 (n) which is represented Soln. : y(n) = x1(n) ⊛ x2(n)
as (O). We take two concentric circles. Plot x1(n) on the outer
x2 (n)
x3 (n) = x1 (n) O circle in the counter clockwise direction and x2(n) on the
DFT {x3 (n)} = DFT { x1 (n) O
x2 (n) } inner circle in the clockwise direction i.e.,
= X3 (k) = X1 (k) · X2 (k)
DFT
x2 (n) X1 (k) · X2 (k)
x1(n) O
Hence, circular convolution reduces to multiplication
while working with the DFT.
We will be solving a few examples after discussing one
more property of the DFT.
3.9 Circular Convolution
One of the most important formula of DFT is that of
circular convolution. We shall now see how to perform
circular convolution.
Fig. P. 3.9.1
DSIP (MU-Sem.7-COMP) 3-48 Discrete Fourier Transform (DFT)
Fig. P. 3.9.1(a)
Fig. P. 3.9.1(d)
We multiply the corresponding samples and add. This
gives us y(0). y(3) =2 1 + 1 2 + 1 3 + 4 4 = 23
ge
y(0) = 4 1 + 2 2 + 1 3 + 1 4 = 15 If we now rotate the inner circle, we come back to the
We now rotate the inner circle in the anticlock-wise starting point. Hence we stop here.
io led
direction by one step. This gives us,
y(n) = {15, 19, 23, 23}
The second method of performing circular convolution
ic ow
Fig. P.3.9.1(c)
y(2) = 1 1 + 1 2 + 4 3 + 2 4 = 23
Fig. P. 3.9.2
DSIP (MU-Sem.7-COMP) 3-49 Discrete Fourier Transform (DFT)
y(3) = 0 1 + 0 – 1 + 2 2 + 1 – 4
= 0
y(n) = {– 7, 1, 0, 0}
Ex. 3.9.3 : Determine
y(n) = x(n) N h (n)
Where
x(n) = {1, 2, 3, 1}; h(n) = {4, 3, 2, 2}
Soln. :
3 4 2 2
y(0) = 1 1 + 0 – 1 + 0 – 2 + 2 – 4 = – 7 y (0) 4223 1
y (1)
=
2
y (2) 2 3 4 2 3
ge
y (3) 2 2 3 4 1
y (0) 17
io led
y (1)
=
19
y (2) 22
y (3) 19
ic ow
n
y (n) = {17,19,22,19 }
bl kn
Fig. P. 3.9.2(b)
Ex. 3.9.4 : For the following sequences
{ 10 0otherwise
n2
at
x1 (n) =
Pu ch
x (n) = {
1 0n2
2 0 otherwise
Te
3+3–1 = 5
We now append zeros to x1(n) and x2(n) to make their
lengths equal to 5.
x2 (n) = { 1,1,1,0,0}
Fig. P. 3.9.2(d)
DSIP (MU-Sem.7-COMP) 3-50 Discrete Fourier Transform (DFT)
Step I :
The circular convolution is performed as follows.
Given :
y(1) 1 1
y(0) 1 0 0 1 1 1
1 0 0 1 x1 (n) = {1, 2, 1, – 2}
y(2) =
1 1 1 0 0
1
Now, X1 (k) = [W4] X1N
y(4) 0 1 0
y(3) 0 1 1 1 0 0
0 1 1 1 1 1 1 1
1 –j –1 j 2
2
1
X1 (k) =
1 –1 1 –1 1
–j
=
23 1 j –1 –2
1
1+2+1–2 2
=
1 – 2j – 1 – 2j = – 4j
1–2+1+2 2
ge
y(n) = {1, 2, 3, 2, 1} 1 + 2j – 1 + 2j 4j
This is the result that we would have got had we used
io led Similarly,
circular convolution.
Let us verify the result by performing linear X2 (k) = [W4] X2N
convolution. We use the tabular method.
ic ow
1 1 1 1 3
1 –j –1 j –2
n
X2 (k) =
1 –1 1 –1 1
bl kn
1 j –1 –j –3
at
Pu ch
3–2+1–3 –1
=
3 + 2j – 1 – 3j =
2–j
9
Te
3+2+1+3
Fig. P. 3.9.4
3 – 2j – 1 + 3j 2+j
Step II :
y (n) = { 1, 2, 3, 2, 1}
Let Y (k) = X1 (k) X2 (k)
Hence we get the same result.
= {2, – 4j, 2, 4j} {– 1,2 – j, 9, 2 + j}
Ex. 3.9.5 : Using the DFT method, obtain the circular
convolution of the following : Y (k) = {– 2,– 4 – 8j, 18, – 4 + 8j}
x1 (n) = [1 2 1 – 2]
Step III :
x2 (n) = [3 – 2 1 – 3]
Verify your result using the graphical method. The result of circular convolution is obtained by performing
1 1 1 1 –2
We begin with computing the DFT of x1(n) and x2(n)
1 1 j –1 –j – 4 – 8j
= =
4
1 –1 1 –1 18
1 –j –1 j – 4 + 8j
DSIP (MU-Sem.7-COMP) 3-51 Discrete Fourier Transform (DFT)
1
– 2 – 4 – 8j + 18 – 4 + 8j 8 2
1 – 2 – 4j + 8 – 18 + 4j + 8 = –4 –1
= =
4
– 2 + 4 + 8j + 18 + 4 – 8j 4 24 6
– 2 + 4j – 8 – 18 – 8 – 4j – 36 –9
y (n) = {2, – 1, 6, – 9}
This is the final Result we verify the result by performing direct circular convolution. We generate a circular matrix of
x1 (n)
y (0) 1 –2 1 2 3
y (1)
=
2 1 –2 1 –2
y (2) 1 2 1 – 2 1
y (3) –2 1 2 1 –3
ge
y (0) 2
y (1)
=
–1
y (2) 6
io led
y (3) –9
y(n) = 2, –1, 6, – 9}
ic ow
Note : Since the next column of the circular matrix will be the
y(0) 4 2 1 1 1
same as the first column we stop. = 1 4
y(1) 2 1 2
The x2 matrix is called a circular matrix. y(2) 1 1 4 2 3
y(3) 2 1 1 4 4
3.9.2(A) Solved Example on Matrix Method y(0) 15
We get y(1) = 19
Ex. 3.9.6 : Perform circular convolution on the given two y(2) 19
sequence x1(n) = {1, 2, 3, 4}, x2(n) = {4, 1, 1, 2}. y(3) 23
Soln. : i.e., y(n) = {15, 19, 19, 23}
Soln. : We generate a circular matrix of x2(n) and multiply This is the same result as obtained using the concentric
by x1(n). circle method.
y(n) = x1(n) ⊛ x2(n) Ex. 3.9.7 : Given the two sequences of length 4 are,
x(n) = {0,1,2,3}, h(n) = { 2,1,1,2}
Find circular convolution
DSIP (MU-Sem.7-COMP) 3-52 Discrete Fourier Transform (DFT)
Soln. : The lengths of x (n) and h (n) are equal. We plot
x (n) on the outer circle in counter clock wise direction, and
h(n) on the inner circle in the clock wise direction. We
multiply and add corresponding elements.
Fig. P. 3.9.7(d)
y (3) = (0 2) + ( 1 1 ) + (2 1 ) + (3 2) = 9
ge
If we rotate one more time, we come back to the starting
Fig. P. 3.9.7(a)
position. Hence we stop the process.
y (0) = (0 2) + ( 1 2 ) + (2 1 ) + (3 1) = 7
io led
y (n) = {7, 9, 11, 9}
We now rotate the inner circle and continue to multiply and Ex. 3.9.8 : Find circular convolution for the following
ic ow
add the corresponding elements. Hence we have sequence using graphical method.
(i) x1 (n) = (n) + (n – 1) + ( n – 2)
n
bl kn
x 2 (n) = 2 (n) – (n – 1) + 2 ( n – 2)
x2 (n) = (n) – (n – 2) + ( n – 4)
Soln. :
Te
y (1) = (0 1) + ( 1 2 ) + (2 2 ) + (3 1) = 9
Since both x1(n) and x2(n) are of equal lengths, we place
x1(n) on the outer circle in the counter clockwise direction
and x2(n) on the inner circular in the clockwise direction.
Fig. P. 3.9.7(c)
y (2) = (0 1) + ( 1 1 ) + (2 2 ) + (3 2) = 11
Fig. P. 3.9.8(a)
DSIP (MU-Sem.7-COMP) 3-53 Discrete Fourier Transform (DFT)
y(0) = (1 2) + (1 2) + (1 ( – 1)) = 3
Fig. P. 3.9.8(d)
y(0) = (1 1) + (1 1 ) + ( – 1 0 ) + (–1 1) + ( 0 0) = 1
Fig. P. 3.9.8(b)
y(1) = (1 ( – 1)) + (1 2) + (1 2) = 3
ge
io led
ic ow
Fig. P. 3.9.8(e)
Fig. P. 3.9.8(c)
at
y (n) = { 3, 3, 3}
(ii) x1(n) and x2(n) can be written is the form Fig. P. 3.9.8(f)
x1 (n) = { 1, 1, – 1, – 1, 0} and
x2 (n) = {1, 0, 1, 0, 1}
Fig. P. 3.9.8(g)
We place x1(n) on the outer circle, and x2(n) on the
inner circle y(3) = (1 0) + (1 1 ) + ( – 1 0 ) + (–1 1) + ( 0 1) = 0
DSIP (MU-Sem.7-COMP) 3-54 Discrete Fourier Transform (DFT)
x2(n) = {1, 1, 1, 0, 0, 0}
Note : In this case we need to append two zeros to x1(n) and
three zeros to x2(n).
y(1) 1 1 0 0 0 1 2
y(0) 1 0 0 0 1 1 1
Fig. P. 3.9.8(h)
ge
circular convolution is max (L1, L2)
y(n) = {1, 3, 6, 6, 4, 1}
3.9.3 Getting Linear Convolution from
io led We now check if this is same as what we would have
Circular Convolution got had we performed linear convolution. We shall again
use the matrix method y(n) = x1(n)* x2(n)
We can get the linear convolution result using circular
ic ow
Pu ch
Given two sequences x1(n) and x2(n) of lengths L1 and y(n) = {1, 3, 6, 6, 4, 1}
L2 respectively, the length of y(n) using linear Hence we see that the two results are the same.
convolution would be L1 + L2 – 1 while the length of
Te
Ex . 3.9.10 : Compute circular convolution of Soln. : We use the circular convolution property
x1 (n) = { 1,1,2,2} DFT
i.e. x1(n) ⊛ x2(n) X1(k) X2(k)
x2 (n) = {1, 2, 3, 4}
We find the DFT’s of x1(n) and x2(n)
Soln. :
X1 = [WN] x1
x2 (n)
y (n) = x1 (n) O
X1(0)
1 1 1 1 1
We generate a circular matrix of x2 (n)
X (1)
1
=
1 – j –1 j 2
214 3 X (2) –1 3
ge
y (0) 143 2 1 1 –1 1
–j 1
1
y (1)
=
1 X (3)
1 1 j –1
y (2) 3 2 1 4 2
io led X1(k) = {7, – 2 – j, 1, – 2 + j}
y (3) 4321 2
Similarly
y (0) 15 X2 = [WN] x2
ic ow
y (1) 17
X (1)
X2(0)
= 1 1 1 1 4
y (2) 15
j 3
n
y (3) 13
2 1 – j –1
=
–1 2
bl kn
X (2) 1 –1 1
–j 2
2
X2(k) = {11, 2 – j, 1, 2 + j}
Ex. 3.9.11: Compute DFT of X (n) = 1, 0 n 2 = 0
X3 = X1(k) X2(k) = {77, – 5, 1, – 5}
Otherwise N = 4, Find | X (k) | and X (k)
Te
x (2) 4
1 –1 1 –1 1
j –5
1 1 1 1 1 3
1 –j –1 j 1 x (3)
3 1 –j –1
X (k) =
1 –1 1 – 1 1 x3 = {17, 19, 22, 19}
1 j –1 –j 0 This is the result that we would obtain if we circularly
convolved x1(n) and x2(n)
X (k) = { 3, – j, 1, j }
x1(n) ⊛ x2(n) = {17, 19, 22, 19}
Now, Let us check our result by performing circular
convolution of x1(n) and x2(n)
Magnitude | X (k) | = {3,1,1,1}
x3(n)= x1(n) ⊛ x2(n)
Imaginary
Phase X (k) = tan –1
Real
x (1)
x3(0)
4 2 2 3 1 Ex. 3.9.15 : Find linear and circular convolution of the
3 =
3 4 2 2 2 following sequences
x (2) 2 3
x1 [n] = [4, – 2, 2, 1]
2 3 4
4 1
3
x (3)
3 2 2 3
x2 [n] = [1, 2, 3]
Ex. 3.9.13 : Compute circular convolution of x1(n) = {1,2,3,4} (i) Linear convolution
and x2(n) = {2,1,2,1}
x1 (n) = [4, – 2, 2, 1]
Soln. :
x2 (n) = [1, 2, 3]
x1(n) = {1,2,3,4}
Number of sample in x1 (n) is L1 = 4
x2(n) = {2,1,2,1}
ge
Number of sample in x2 (n) is L2 = 3
x2(n)
y(n) = x1(n)O io led
OR O
y(n) = x1(n) N x2(n)
So from linear convolution number of samples will be,
L2 + L2 – 1 = 6
We generate a circular matrix of x2(n)
ic ow
=
y (2) 2 1 2 1 3
y (3) 1 2 1 2 4 We assume the first value as the origin,
at
Pu ch
y (0) 14
y (1) 16
Te
=
y (2) 14
y (3) 16
y (1)
=
1 should be equal.
y (2) 2 3 4 1 2
y (3) 1 2 3 4 1
We append one zero to x2 (n)
y (1) =
14 x2(n) = {1, 2, 3, 0}
y (2) 16
y (3) 14 We generate a circular matrix of x2(n)
210 3
y (0) 103 2 4
Soln. :
y (1)
=
–2 Step I : The four point DFT of x1 (n) is X1 (k) and it is given
y (2) 3 2 1 0 2
y (3) 0321 1
by,
X1 (k) = [ W4 ] x1
y (0) 12
y (1) 9
1 1 1 1
y (2)
=
10 1 –j –1 j
y (3) –1
We have, [ W4 ] =
1 –1 1 – 1
1 j –1 –j
y(n) = {12, 9, 10, 1}
1 1 1 1 1
Ex. 3.9.16 : Find circular convolution of two finite
X1 (k) =
1 –j –1 j 2
·
duration signals 1 –1 1 – 1 3
–j 1
ge
x1 (n) = {1, – 1, – 2, 3, –1} 1 j –1
–2–j
x2 (n) = { 1, 2, 3} 7
io led
Soln. : For circular convolution, length of both signals =
1
should be equal. We append two zeros to x2(n).
–2+j
ic ow
x2 (n) = { 1, 2, 3, 0, 0}
Similarly, X2 (k) = [ W4 ] x2N
3
Now, 1 1 1 1 4
at
Pu ch
x2 (n)
y (n) = x1 (n) O X2 (k) =
1 –j –1 j
1 –1 1 – 1 2
–j 2
Te
4 – 3j – 2 + 2j 2–j
4+3+2+2 11
y (0) 1 0 0 3 2 1
y (1) 2 1 0 0 3 –1
X2 (k) =
y (2)
=
3 2 1 0 0
–2
4–3+2–2
4 + 3j – 2 – 2j
1
2+j
y (4) 0 0 3 2 1 –1
y (3) 0 3 2 1 0 3
X2 (k) = { 11 , 2 – j , 1 , 2 + j }
y (0) 8
Step II : Now according to property of circular convolution,
y (1) –2
x1 (n) O
* x2 (n) = X1 (k) · X2 (k) = Y (k)
y (2) = –1
y (4) –1
y (3) –4 Y (k) = { 7 , – 2 – j , 1 , – 2 + j }
· { 11 , + 2 – j , 1 , 2 + j }
Y (k) = { 77 , – 5 , 1 , – 5 }
y (n) = { 8, – 2, – 1, – 4, – 1}
Step III : Let the result of x1 (n) O
* x2 (n) be sequence y(n).
Ex. 3.9.17 : Use the four point DFT and IDFT to determine
It is obtained by computing IDFT of Y (k).
the circular convolution of sequences
x1 (n) = (1, 2, 3, 1) x2 (n) = (4, 3, 2, 2) According to the definition of IDFT we have,
1 *
y (n) = [ WN ] · XN
N
DSIP (MU-Sem.7-COMP) 3-58 Discrete Fourier Transform (DFT)
1 * We perform element by element multiplication
= [ W4 ] · YN
4
Y (k) = { 21, – 7 + 4 j, – 3, – 7 – 4 j}
–5
1 1 1 1 77
1 1 +j –1 –j We finally compute the IDFT of y (k),
y (n) =
4 1 –1 1 –1
1 1 *
1 –j –1 +j –5 Now y (n) =
N
[W4 ] YN
1
68 17 1 1 1 21
1 1 – j 4j
1 76 19 j –1 – 7 +
y (n) =
y (n) = = 4 1 –1 1 – 1 – 3
22
4 88 1 –j –1 –j – 7 – 4j
76 19
21 –7 + 4j –2 3 – 7 – 4j 2 4
y (n) = {17‚ 19‚ 22‚ 19}
= 21 + 7 – 4j – 3 + 7 + 4j =
1 21 – 7j + 4j + 3 + 7j + 4j 1 16
4 4 32
Ex. 3.9.18 : Find the response of FIR filter with impulse 21 + 7j – 4j2 + 3 – 7j – 4j2 32
ge
response h(n) = {1, 2, 4} to the input sequence x (n) = {1, 2}
using circular convolution. y (n) = {1, 4, 8, 8}
Soln. :
io led
Step I :
This is the final response of the FIR filter.
x (n) = {1, 2}, h (n) = {1, 2, 4}
ic ow
Verify.
Here L1 = 2 and L2 = 3
n
Let us, Verify the result by performing linear convolution
bl kn
We compute the DFT of x(n) and h (n) and use the property,
DFT
h (n) X (k) H(k)
x (n) O Fig. P. 3.9.18
1 1 1 1 1
X (k) = 1 – 1
1 –j –1 j 2 y(n) = { 1, 4, 8, 8}
1 – 1 0
1 j – 1 – j 0 Hence we get the same result.
Fig. P. 3.9.19(c)
y (0) =(1 2) + (2 0) + (3 1) + (2 0) = 5
ge
io led
ic ow
Fig. P. 3.9.19
n
bl kn
Hence we have,
at
Pu ch
Fig. P. 3.9.19(d)
y (0) =(1 0) + (2 2) + (3 0) + (2 1) = 6
Te
y (1) x x (1)
x2 (0) x2 (3) x2 (2) x2 (1) x1 (0)
y (0) =(1 1) + (2 0) + (3 2) + (2 0) = 7 y (0)
2
(3) x2 (2) x2 (1) 2 1
=
1 0 2 =
y (2) 2 0 1 0 3 5
y (3) 0 2 0 1 2 6
y (n) = { 7, 6, 5, 6 }
which is the same as obtained using the graphical
Fig. P. 3.9.19(b) method.
DSIP (MU-Sem.7-COMP) 3-60 Discrete Fourier Transform (DFT)
(ii) Find linear convolution using circular convolution. Since response (filter), then the filtered output signal y (n) is
length of x1 (n) = 4 and length of x2 (n) = 4, linear given by the linear convolution operation.
convolution would give us a result of length y (n) = x(n) h (n)
L1 + L2 – 1 = 4 + 4 – 1 = 7 +
y (0) 1 0 0 0 0 2 0 1
processed blocks are then, appended (connected) to
ge
y (1) 0 1 0 0 0 0 2 2
=
each other to obtain the final filtered output y (n).
y (2) 2 0 1 0 0 0 0 3
y (3) 0 2 0 1 0 0 0 2 There are two methods of performing this kind of
io led
filtering
y (4) 0 0 2 0 1 0 0 0
y (5) 0 0 0 2 0 1 0 0 1. Overlap - save method.
2. Overlap - add method.
ic ow
y (6) 0 0 0 0 2 0 1 0
y (n) = {1, 2, 5, 6, 6, 4, 0} We shall discuss both these methods in detail.
n
We now verify this result by performing regular
3.10.1 Overlap - Save Method
bl kn
convolution.
y (n) = x1 (n) * x2 (n) As mentioned earlier, we break x(n) into smaller blocks
at
Pu ch
ge
io led
ic ow
Fig. 3.10.1
Once these block are created, each of these are "circularly convolved" with h (n).
n
i.e. h (n)
y1 (n) = x1 (n) O
bl kn
h (n)
y2 (n) = x2 (n) O
at
Pu ch
∶ ∶ etc.
The final filtered output y (n) is obtained by discarding the first (M – 1) values of each result. y1(n), y2 (n), and
Te
Fig. 3.10.2
DSIP (MU-Sem.7-COMP) 3-62 Discrete Fourier Transform (DFT)
This y (n) is the same as what we would obtain by result. In short, we discard the first (M – 1) = 2 values of
i.e. h (n)
y(n) = x(n) O
ge
Ex. 3.10.1 : Let x(n) = {1, 2, 3, 4, 5, 6, 7}
and h (n) = {1, 0, 2} io led
Perform convolution using overlap save method.
Soln. : We choose a block size of N. In this method, each
block contains (M – 1) data points of the previous block
ic ow
followed by L new data points. For the first block, the first
(M – 1) values are set to zero. In our case M – 1 = 2. We
n
choose N = 5 and L = 3.
bl kn
x(n) = {1, 2, 3, 4, 5, 6, 7}
at
Pu ch
ge
io led
ic ow
n
bl kn
Fig. 3.10.3
at
Pu ch
Te
Fig. 3.10.4
DSIP (MU-Sem.7-COMP) 3-64 Discrete Fourier Transform (DFT)
3.10.3 Solved Examples on Method Ex. 3.10.3 : Find linear convolution using overlap-add and
overlap-save method of the following sequences :
Let us solve an example to understand the method just
discussed. x[n] = {1, 2, – 1, 2, 3, – 2, – 3, – 1, 1, 1, 2, – 1};
ge
Overlap - add method M–1 = 2
In this, the input is divided into blocks of data of size L
io led
and (M – 1) zeros are appended to it. This makes the size of
Now to make each block we need L = 2 data from
data blocks N = L + (M – 1). x (n). The different blocks are formed as follows :
In our example we choose a block size of N = 5. For the 1st block, we append M – 1 = 2 zeros
ic ow
x(n) = {1, 2, 3, 4, 5, 6, 7}
x1(n) = {1, 2, 3, 0, 0}
at
Pu ch
x2(n) = {4, 5, 6, 0, 0}
x3(n) = {7, 0, 0, 0, 0}
Te
2 1 0 3
We create a circular of h(n) 1032
–3
2 1 0 3 00
1032
y5 (n) =
–1
3 2 1 0 1
1
y1 (n) =
3 2 1 0 12 0 3 2 1
0 3 2 1
– 6 –1 + 0 + 3 – 24
–3+0+3+2
0 + 0 + 0 + 6 76
0+0+3+4
=
= =
– 9 – 2 + 1 + 0 – 100
=
0 + 0 + 1 + 0 14 0 – 3 + 2 + 1
0 + 0 + 2 + 2
y5 (n) = {2, – 4, – 10, 0} ...(5)
y1 (n) = {7, 6, 1, 4} ....(1)
y2 (n) = h (n)
x2 (n) O h (n)
y6 (n) = x6 (n) O
2 1 0 3 21
1032
2 1 0 3
1032
ge
1
y2 (n) = 1
3 2 1 0 – 21 y6 (n) =
2
0 3 2 1 3 2 1 0
0 3 2 1 –1
io led
2 + 2 + 0 + 6 102
1+0–3+4
= 2 + 1 + 0 – 3 50
1+0+6 –2
=
ic ow
=
3 + 4 – 1 + 0 66 =
0 + 6 – 2 + 2 3 + 2 + 2 + 0 76
0 + 3 + 4 – 1
n
bl kn
2 1 0 3 –12
1032
Pu ch
h (n)
y7 (n) = x7 (n) O
y3 (n) =
– 23 2 1 0 3
1032
Te
3 2 1 0
2
0 3 2 1 y7 (n) =
–1
– 2 + 2 + 0 – 6 – 46
–1+0+9 –4 3 2 1 0 0
0
= 0 3 2 1
=
– 3 + 4 + 3 + 0 104
2 +0+0+0
22
0 + 6 + 6 – 2 4 –2+0+0 =
=
y3 (n) = {4, – 6, 4, 10} ...(3)
6 – 2 + 0 + 0 4
–3
h (n)
y4 (n) = x4 (n) O 0 – 3 + 0 + 0
2 1 0 3 – 23
1032
y7 (n) = {2, 2, 4, – 3} ...(7)
y4 (n) =
3 2 1 0 –– 13 The final output y (n) is obtained by discarding initial
0 3 2 1 2 samples from each output block and then by connecting
6 – 2 + 0 – 3 – 18
3+0–9 –2 all output blocks one after other.
=
= y (n) = {1, 4, 6, 6, 4, 10, 2, – 13, – 1, 0, 0, 7,
9 – 4 – 3 + 0 – 132 6, 4, – 3}
0 – 6 – 6 – 1 Let us verify the result obtained by using regular linear
y4 (n) = {– 8, 1, 2, – 13} ...(4) convolution we use the tabular method.
h (n)
y5 (n) = x5 (n) O
DSIP (MU-Sem.7-COMP) 3-66 Discrete Fourier Transform (DFT)
x=0 y=0
ge
3. Circular 3.12.1 The Separability Property
DFT
time shift x (n – m)N io led e –j2km/N X(k) This property states that a 2-D DFT can be separated
into two 1-D DFTs.
4. Circular We know (assume a square image)
DFT
x (n) e –j2km/N X(k – m )
–j2
frequency N N–1 N–1 ux vy
ic ow
reversal x ((– n)) N x((– k ))N This can be split up as,
N–1 ux N – 1 –j2vy
at
–j2 N
Pu ch
F(u, v) = e N f(x, y) e
6. Complex
DFT x=0 y=0
conjugate x * ((n)) N x((– k )) N
N–1 vy
Te
–j2
Let F(x, v) = f(x, y) e N
DFT
x (n) X(N – K) y=0
N–1 ux
–j2
7. Parsevals F(u, v) = f(x, v) e N
N –1 N –1
theorem 1 y=0
| x (n) | 2 = | X (k) | 2
N
n=0 n=0 As stated, the principle advantage of the separability
property is that the 2-D DFT can be obtained in two steps
8. Circular DFT by successive application of 1-D DFT.
x1(n) * x2 (n) X1(k) · X2 (k)
convolution F(u, v) can be obtained by applying 1-D DFT along the
rows and then along the columns. One could also take the
1-D DFT first along the columns and then along the rows.
Fig. 3.12.1
DSIP (MU-Sem.7-COMP) 3-67 Discrete Fourier Transform (DFT)
3.12.2 Solved Examples on 2- DFT
0 1 2 1
1 2 3 2
2 3 4 3
1 2 3 2
Soln. : We have studied the 1-D DFT matrix. We shall use the DFT along the rows and then along the columns.
Length of each row is N = 4 we need a 4 H 4 DFT matrix.
1 1 1 1 0 4
1 – j – 1 j = –2
1
DFT of 1
st
row
1 – 1 1 – 1 2 0
1 j – 1 – j 1 –2
ge
1 1 1 1 1 8
1 – j – 1 j = –2
2 nd
io led DFT of 2 row
1 – 1 1 – 1 3 0
1 j – 1 – j 2 –2
1 1 1 1 2 12
ic ow
1 – j – 1 j = –2
3
DFT of 3
rd
row
1 – 1 1 – 1 4 0
1 j – 1 – j 3 –2
n
bl kn
1 1 1 1 1 8
1 – j – 1 j = –2
2
DFT of 4
th
row
1 – 1 1 – 1 3 0
at
Pu ch
1 j – 1 – j 2 –2
8
4 –2 0 –2
Te
1 1 1 1 4 32
1 – j – 1 j = –8
8
DFT of 1
st
column
1 – 1 1 – 1 12 0
1 j – 1 – j 8 –8
1 1 1 1 –2 –8
1 – j – 1 j – 2 = 0 DFT of 2
nd
column
1 – 1 1 – 1 –2 0
1 j – 1 – j –2 0
1 1 1 1 0 0
1 – j – 1 j = 0
0
DFT of 3
rd
column
1 – 1 1 – 1 0 0
1 j – 1 – j 0 0
1 1 1 1 –2 –8
1 – j – 1 j – 2 = 0 DFT of 4
th
column
1 – i 1 – i –2 0
1 j – 1 – j –2 0
DSIP (MU-Sem.7-COMP) 3-68 Discrete Fourier Transform (DFT)
32 –8 0 –8
–8 0 0 0
The final DFT of the entire image is
0 0 0 0
–8 0 0 0
ge
method. Computation of Inverse DFT was explained.
F = TfT ...( 2 )
Drawing the Magnitude as well as the Phase spectrum was
We shall solve the same example by using this formula carried out. We also explained how to identify the
io led
Ex. 3.12.2 : Find the DFT of the given image.
frequency components from the x- axis of the DFT
1 2 1
spectrum. Properties of the DFT were listed and examples
10
2 3 2 were solved using each of the properties. The chapter also
ic ow
is given below
1 1 1 1
at
1 –j –1 j
transform.
1 j –1 –j Q. 2 State and prove circular convolution property of
Te
F = 1 –1 1 –12 3 4 3
1 –j –1 j 1 2 3 2 Q. 3 State and prove properties of Discrete Time Fourier
Transform (DTFT).
1 j –1 –j1 2 3 2
Q. 4 Explain the convolution property of Fourier transform
1 1 1 1 of a DT signal.
1 –j –1 j
1 –1 1 –1 Q. 5 State and prove following properties of Fourier
1 j –1 –j transform :
4 Fast Fourier Transform
Syllabus :
Need of FFT, Radix-2 DIT-FFT algorithm, DIT-FFT Flow graph for N = 4 and 8, Inverse FFT algorithm.
4.1 Introduction
ge
We studied the Discrete Fourier Transform (DFT) in the
Chapter 3. io led
The DFT is used to identify the frequency components
present in a discrete time signal. The DFT converts a time
domain signal into a frequency domain signal. We have also written the number of multiplication and
ic ow
A N–point DFT is given by the equation addition required to calculate each X(k)
N–1 X(0) = 1·x(0) + 1· x(1) + 1· x(2) + 1· x(3) 4 multi. & 3 add
n
nk
X(k) = x(n) WN ; k =0, 1, , N–1 (4.1.1) X(1) = 1·x(0) + (–j)·x(1) + (–1)·x(2) + j·x(3) 4 multi. & 3 add
bl kn
n=0
X(2) = 1·x(0) + (–1)x(1) + (1)·x(2) + –(1)x(3) 4 multi. & 3 add
In the matrix form it is given by the equation
X(3) = 1·x(0) + j x · (1) + (–1)·x(2) + –(j)·x(3) 4 multi. & 3 add
at
Pu ch
X = [W]x (4.1.2)
16multi. & 12add
Ex. 4.2.1 : Compute the DFT of the sequence Therefore computing the DFT is computationally very
expensive.
x(n) = {0, 1, 2, 1}.
It has been mentioned in earlier chapters that because
Soln. : Since the length of the signal is 4,
of high sampling rates in the real world, the length of x(n) is
N = 4 4-Point DFT very large and runs into thousands of samples.
We generate a 44 DFT matrix and use Computing the DFT of such signals would require a
Equation (4.1.2). machine which has a lot of computation power. It would
also take a lot of time.
To cut a long story short, the DFT is computationally
very demanding and we require something that would
reduce the number of computations.
This is where the Fast Fourier Transform comes in.
DSIP (MU-Sem. 7-COMP) 4-2 Fast Fourier Transform
Fast Fourier Transform (FFT) The two commonly used algorithms are
In 1965, Cooley and Tukey proposed a method of 1. Decimation in Time FFT (DIT-FFT)
computing the DFT which required only N log2 N 2. Decimation in Frequency FFT (DIF-FFT)
calculations. We shall derive and discuss each one in detail but
This method came to be known as the Fast Fourier before doing that let us try to visualize a N-point DFT
Transform (F.F.T)
formula.
The FFT refers to a class of algorithms for efficiently
computing the DFT. We know a N-point DFT is given by the equation
N-1
Hence FFT is not a new transform but a set of
x(n) WN ;
nk
algorithms used for computing the DFT efficiently. X(k) = k =0, 1, , N– 1
n=0
The results obtained from the DFT and the FFT are the
same. Here x(n) is the input and X(k) the output. This
The computational efficiency of the FFT becomes clear equation can be pictorially represented as shown in
when the values of N2 and N log2 N are compared for Fig. 4.2.1
ge
several values of N.
Number of Number of
Number of
io led
computations computations
Samples (FFT) N log2 N
(DFT) N2
ic ow
32 1024 160
128 16,384 896
n
2048 4,194,304 22,528
bl kn
Pu ch
The DFT block computes the DFT of the input x(n) and
As mentioned earlier, FFT is an algorithm. The
gives us the output X(k).
commonly used technique is called the RADIX-2 FFT
Te
The FFT exploits these two properties to reduce the Here we exploit the symmetric and periodic property
number of complex multiplications. of the twiddle factor WN
k + N/2 k
The basic principle of the FFT algorithm is to break WN = – WN Symmetric
(decompose) a N-point DFT into smaller DFTS. As k+N k
WN = WN Periodic
mentioned earlier, FFT is an algorithm and is known as
Radix-2 which simply means that the number of These two important properties reduce the number of
output -points is expressed an a power of 2 i.e. N=2 ,m computations.
where m is an integer. A N-point-DFT is given by the equation,
Hence when the FFT algorithm breaks a DFT into N–1
nk
smaller DFTS’ the output of the smaller DFTS’ are X(k) = x(n) WN k = 0, 1, 2, … N – 1
always powers of 2. n=0
DSIP (MU-Sem. 7-COMP) 4-3 Fast Fourier Transform
N
In decimation-in-time technique, we split the input 2 –1
nk
x(n) into odd and even parts. Let
x(2n) WN/2 = F1 (k)
n=0
nk
nk
X(k) = x(n) WN + x(n) WN N
n even n odd 2 –1
N
nk
N N and x(2n + 1) WN/2 = F2 (k) ; k = 0, 1, …
2 –1 2 –1 2
n=0
2nk (2n + 1)k
X(k) = x(2n)WN + x(2n + 1)WN k
n=0 n=0 X(k)= F1 (k) + WN F2 (k) … (4.3.2)
N N
2 –1 2 –1 N
This equation gives us the first 2 values
x(2n) WN + x(2n + 1)W2nk
2nk
X(k) =
N
n=0 n=0 Since F 1 (k) and F2 (k) are periodic with period N/2 we
N N
2 –1 2 –1 can write
ge
2nk k
X(k) = x(2n) WN + WN x(2n + 1)W2nk F1 (k + N/2) = F1 (k) and
N
n=0 n=0
F2 (k + N/2) = F2 (k)
2
Now, WN = WN/2
io led k + N/2 k
also WN = – WN
N N
2 –1 2 –1 Equation (4.3.2) can be written as,
nk nk
X(k) = x(2n) WN/2 + x(2n + 1) WN/2 N
ic ow
k
X(k) = F1 (k) + WN F2 (k) ; k = 0,1, … –1
n=0 n=0 2
X k +
N N
n
k
= F (k) – WN F2 (k); k = 0, 1, … – 1
N/2 point DFT N/2 point DFT 2 1 2
bl kn
…(4.3.1) … (4.3.3)
at
2
We observe that F1(k) requires (N/2) complex multiplications and the same applies to F2 (k). Furthermore, there are
Pu ch
N/2 additional complex multiplications required to compute WNk F2(k). Hence the computation of X(k) requires
complex multiplications which is almost half the computations required by the conventional method.
Te
2
N2 N
2
N N
+ = +
2 2 2 2
Let us take an example where N = 8,
Equation (4.3.3) can be shown using a signal flow graph.
Since in DIT - FFT, we have split the input x(n) into even and odd parts, we have
Fig. 4.3.1
DSIP (MU-Sem. 7-COMP) 4-4 Fast Fourier Transform
As stated earlier, F1(k) and F2 (k) are N/2 point DFT’s (4 point DFT’s if N = 8). These can be further split up into odd and
even parts. We rewrite Equation 4.3.1.
N N
2 –1 2 –1
nk k nk
i.e. X(k) = x(2n) WN/2 + WN x(2n + 1) WN/2
n=0 n=0
F1(k) F2 (k)
Splitting up F1 (k) and F2 (k) into odd and even parts, we get,
N N
2 –1 2 –1
nk k nk
X(k) = x(2n) WN/2 + WN x(2n + 1) WN/2
ge
n=0 n=0
io led
2 parts of N/4 each 2 parts of N/4 each
(A) (B)
ic ow
N N
N
4 –1 4 –1
2 –1
x(4n) WN/2
nk 2nk (2n + 1) k
n
(A) F1 (k) =
x(2n) WN/2 = + x(4n + 2) WN/2
bl kn
n=0 n=0
n=0
N N
u –1 u –1
at
Pu ch
2nk 2nk k
= x(un) WN/L + x(4n + 2) WN/2 .WN/2
n=0 n=0
Te
= x(un) WN/2
2nk
+ WN/2
k
x(un + 2) W2nk
N/2
2 1
Now WN/2 = WN/4
N N
N
4 –1 4 –1
2 –1
nk nk k nk
F1 (k) =
x(2n) WN/2 =
n=0
x(4n) WN/4 + WN/2
n=0
x(4n + 2) WN/4
n=0
nk k nk
F1 (k) = x(4n) WN/4 + WN/2 x(4n + 2) WN/4
n=0 n=0
N
4 –1
nk
Let x(4n) WN/4 = G1(k)
n=0
N
4 –1
nk
and x(4n + 2) WN/4 = G2 (k)
n=0
DSIP (MU-Sem. 7-COMP) 4-5 Fast Fourier Transform
k
F1(k) = G1(k) + WN/2 G2 (k)
N
This equation will give us the first 4 values
k
F1(k) = G1(k) + WN/2 G2 (k)
k = 0, 1, 2, …, 4 – 1
k N
F1(k + N/4) = G1(k) – WN/2 G2 (k) … (4.3.4)
k
F2 (k) = H1 (k) + WN/2 H2 (k)
ge
k
F2 (k + N/4) = H1 (k) – WN/2 H2 (k)
io led
For N = 8, k will have values 0, 1.
We have split F1 (k) and F2 (k) which were N/2 point DFT’s into two N/4 point DFT’s each.
We draw the signal flow graph using Equation (4.3.4) and the earlier Fig. 4.3.1. Let N = 8
ic ow
n
bl kn
at
Pu ch
Te
Fig. 4.3.2
A 2-Point DFT is drawn as,
Fig. 4.3.3
Hence the final signal flow graph is shown in Fig. 4.3.4.
DSIP (MU-Sem. 7-COMP) 4-6 Fast Fourier Transform
ge
io led Fig. 4.3.4 : 8-point DIT-FFT Butterfly diagram
This diagram is also called an 8-point butterfly diagram.
The DIT-FFT refers to the method in which the input samples are broken into odd and even parts. This time decimation
leads to the scrambled order of the input.
ic ow
The shuffling of the input data is known as bit-reversal. This is because the order of the input data can be obtained by
reversing the bits of the binary representation of the normal input data index order
Te
Soln. :Since N = 8, we draw a 8-point DIT-FFT Butterfly diagram remember, the input to the network is in the bit reversed
order.
ge
io led
Fig. P.4.4.1
ic ow
x(n) = 1 , 2 , 3 , 2 , 1 , 5 , 2 , 1 } Stage 2
n
x(0) x(1) x(2) x(3) x(4) x(5) x(6) x(7) 0
F1(0) = G1 (0) + W4G2 (0) = 2 + 1 · (5) = 7
bl kn
Here W40 = 1 1
F1(1) = G1 (1) + W4G2 (1) = 0 + (– j)(1) = – j
-j2
at
Pu ch
1 4
W4 = e = cos – j sin =–j 0
2 2 F1(2) = G1 (0) –W4G2 (0) = 2 – 1 · (5) = – 3
Similarly, 1
F1(3) = G1 (1) –W4G2 (1) = 0 – (– j)(1) = +j
Te
0
W8 = 1 0
–j2·
F2(0) = H1 (0) + W4H2(0) = 7 + 1 · (3) =10
1 8
W8 = e = cos – j sin = 0.707 –j0.707 1
F2(1) = H1 (1) + W4H2(1) = –3 + (– j)(1) =– 3–j
4 4
–j2·
2 8 0
F2(2) = H1 (0) –W4H2(0) =7 – 1 · (3) =4
W8 = e = cos – j sin = –j
2 2
1
–j2· F2(3) = H1 (1) –W4H2(1)
3 8 3 3
W8 = e = cos – j sin = –0.707 –j0.707
4 4 = –3 – (– j)(1) =– 3 + j
We write down the equations at each stage and
Stage 3
calculate the outputs.
0
Stage 1 X(0) = F1(0) + W8F2(0) = 7 + 1 · (10) =17
G1 (0) = x(0) + x(4) = 1 + 1 = 2 1
X(1) = F1(1) + W8F2(1)
G1 (1) = x(0)–x(4) = 1 – 1 = 0
= – j + (0.707 – j 0.707)(– 3 – j)
G2 (0) = x(2) + x(6) = 3 + 2=5
= – 2.83 + j0.41
G2 (1) = x(2) – x(6) = 3 – 2 = 1 2
X(2) = F1(2) + W8F2(2)
H1 (0) = x(1) + x(5) = 2 + 5 = 7
= – 3 + (– j) (4) =– 3 – j4
H1 (1) = x(1) – x(5) = 2 – 5 = – 3 3
X(3)= F1(3) + W8F2(3)
H2 (0) = x(3) + x(7) = 2 + 1 = 3
= j + (– 0.707 – j0.707) (– 3 + j)
H2 (1) = x(3) – x(7) = 2 – 1 = 1 = 2.83 + j2.41
DSIP (MU-Sem. 7-COMP) 4-8 Fast Fourier Transform
0
X(4) = F1(0) – W8F2(0) =7 – 1 · (10) = – 3
1
X(5) = F1(1) – W8F2(1) = – j–(0.707 – j0.707) (– 3 – j) = 2.83 – j2.41
2
X(6) = F1(2) – W8F2(2) = – 3 – (– j) (4) =– 3+ j4
3
X(7) = F1(3) – W8F2 (3) = j – (– 0.707 – j0.707) (– 3 + j) = – 2.83 – j0.41
X(k) = {17, – 2.83 + j0.41, – 3–j4,2.83 + j2.41, – 3, 2.83 – j2.41, – 3 + j4, – 2.83 – j0.41}
Ex. 4.4.2 Find s-point DIT of the sequence x(n) = {1, 2, 3, 4, 4, 3, 2, 1} using DIT Radix 2 FFT
Soln. : Since N = 8, we draw a 8-point DIT-FFT diagram
x(n) = { 1 , 2 , 3 , 4 , 4 , 3 , 2 , 1 }
x(0) x(1) x(2) x(3) x(4) x(5) x(6) x(7)
ge
io led
ic ow
n
bl kn
at
Pu ch
Te
Fig. P. 4.4.2
F2(1) = H1 (1) +
1
W4 H2(1) = – 1 + (– j) (3) = – 3 – j3 = – 5.828 + j2.414
0
F2(2) = H1 (0) – W4 H2(0) = 5 – 1 (5) = 0
X(k) = { 20, – 5.828 – j2.414, 0, – 0.172 – j0.414, 0,
1
F2(3) = H1 (1) – W4 H2(1) = – 1 – (– j) (3) = – 1 + j3 – 0.172 + j0.414, 0, – 5.828 + j 2.414
Stage 3
0
X(0) = F1 (0) + W8 F2 (0) = 10+ (1) (10) = 20 Ex. 4.4.3 : Given x(n)=2n. Find X(k) using DIT-FFT
1
X(1) = F1(1) + W8 F2 (1) algorithms. Assume x(n) is of length 8.
Soln. : Here N=8we vary n from 0to 7.
= (– 3 – j) + (0.707 – j 0.707) (– 1 – j3)
x(n) = 2n, 0 n <7
= – 5.825 – j 2.414
x(0) = 20=1
ge
2
X(2) = F1(2) + W8 F2 (2)
x(1) = 21 =2
= 0 + (– j) (0) = 0 x(2) = 22 =4
io led
3
X(3) = F1(3) + W8 F2 + (3) x(3) = 23 =8
= (– 3 + j) + (– 0.707 – j0.707) (– 1 + j3) x(4) = 24 =16
ic ow
1
X(5) = F1(1) – W8 F2 (1)
x(n) = {1, 2, 4, 8, 16, 32, 64, 128}
= (– 3 – j) – (0.707 – j0.707) (– 1 – j3)
at
Pu ch
Fig. P.4.4.3
0
Here W4 = 1
–j2
1 4
·1
W4 = e = cos – j sin = – j
2 2
DSIP (MU-Sem. 7-COMP) 4-10 Fast Fourier Transform
0
Similarly, W8 = 1 = (– 15 + j60) + (0.707 – j0.707)(– 30 + j120)
–j2
1 8
·1 = 48.64 + j166.07
W8 = e = cos – j sin
2 2
X(2) = F1(2) + W82 F2(2)
= 0.707 – j 0.707
–j2 = – 51 + (– j) (– 102) =– 51 + j102
2 8
·2
W8 = e = cos – j sin = – j X(3) = F1(3) + W83 F2(3)
2 2
–j2
3 8
·3 3 3 = (– 15 – j60) + (– 0.707 – j0.707)(– 30 – j120)
W8 = e = cos – j sin
4 4
= – 78.64 + j46.07
= – 0.707 – j 0.707
X(4) = F1(0) – W08 F2(0) = 85 – 1 · (170) = – 85
We write down the equations at each stage
Stage 1 X(5) = F1(1) – W18 F2(1)
G1 (0) = x(0) + x(4) = 1 + 16 = 17 = (– 15 + j60) – (0.707 – j0.707) (– 30 + j 120)
ge
G1 (1) = x(0) – x(4) = 1–16 = – 15
= – 78.64 – j46.07
G2 (0) = x(2) + x(6) = 4 + 64 = 68
io led X(6) = F1(2) – W28 F2(2)
G2 (1) = x(2) – x(6) = 4 – 64 = – 60
= – 51 – (– j)(– 120)=–51 – j102
H1 (0) = x(1) + x(5) = 2 + 32 = 34
X(7) = F1(3) – W38 F2(3)
H1 (1) = x(1) – x(5) = 2 – 32 = – 30
ic ow
0
F1 (0) = G1(0) + W4 G2 (0) =17 + 1 ·(68) = 85
Pu ch
– 51 – j102,48.6 – j166.07}
F1 (1) = G1(1) + W14 G2 (1)
Ex.4.4.4 : Compute the DFT of x(n)= {1,0,2,0,3,0,4,0} using
Te
= – 15 + (– j) (– 60) = – 15 + j60
0
DIT-FFT.
F1 (2) = G1(0) – W4 G2 (0)
Soln. : Since N = 8, we drawn a 8-point DIT-FFT Butterfly
= 17 – 1(68) = –51 diagram. The input is in the bit reversed order.
F1 (3) = G1(1) – W14 G2 (1) x(n) = {1, 0, 2, 0, 3, 0, 4, 0}
Here W40 = 1
= – 15 – (– j)(– 60) =–15 – j 60
–j2 · 1
F2 (0) = H1(0) + W04 H2 (0)
W14 = e u
= cos – j sin = – j
2 2
= 34 + 1 · (136) = 170 Similarly,
1
F2(1) = H1(1) + W4 H2(1) W08 = 1
–j2 · 1
= – 30 + (– j)(– 120) =– 30 + j120
W18 = e 8
= cos – j sin = 0.707 – j0.707
0 4 4
F2(2) = H1(0) – W4 H2(0) =34 – 1 · (136) = – 102 –j2 · 2
F2(3) = H1(1) –
1
W4 H2(1) W28 = e 8
= cos – j sin = – j
2 2
–j2 · 3
= – 30 – (– j)(– 120) = – 30 – j120 3 3
W38 = e 8
= cos – j sin = – 0.707 – j0.707
4 4
Stage 3
We write down the equation at each stage and calculate
X(0) = F1(0) + W80 F2(0) = 85 + 1(170) = 255
the outputs
X(1) = F1(1) + W81 F2(1)
DSIP (MU-Sem. 7-COMP) 4-11 Fast Fourier Transform
ge
io led
Fig. P. 4.4.4
= –2+j2
H2 (0) = x(3) + x(7) = 0 + 0 = 0
X(2) = F1(2) + W28F2 (2) = – 2 + (– j) (0) = – 2
H2 (1) = x(3) – x(7) = 0 – 0 = 0
X(3) = F1(3) + W38F2(3)
Stage 2
= (– 2 – 2j) + (– 0.707 – j 0.707) · 0
F1 (0) = G1(0) + W04G2(0) = 4 + 1 ·(6) = 10
= – 2– j 2
F1 (1) = G1(1) + W14G2 (1) = – 2 + (– j) (– 2)
X(4) = F1(0) – W08F2 (0) = 10 – 1 · (0) = 10
= –2–j2 x(6) = – 1
x(7) = – 1.2
X(k) = {10, – 2 + j 2, – 2, – 2 – j2, 10,
x(n) = {0, 1.2, 1, 0.2, 0, – 0.2, – 1, – 1.2}
– 2 + j 2, – 2,–2 – j 2} x(0) x(1) x(2) x(3) x(4) x(5) x(6) x(7)
ge
n
To obtain a sampled version of x(t), we replace t by . Similarly,
Fs
W08 = 1
io led
Here Fs = 8000 samples /sec
–j2 · 1
W18 = e 8
x(n) = sin
21000n 22000n = cos – j sin = 0.707 – j 0.707
+ 0.5 sin F 4 4
F
ic ow
s s –j2 · 2
W28 = e 8
x(n) = sin
2n 22000n = cos – j sin = – j
2 2
8000 + 0.5 sin 8000
n
–j2 · 3
3 3
bl kn
n n
x(n) = sin + 0.5 sin
W38 = e 8
= cos – j sin
(1) 4 4
4 2
at
= – 0.707 – j 0.707
Pu ch
4 2
Similarly, x(1) = 1.2
x(2) = 1
Fig. P.4.4.5
DSIP (MU-Sem. 7-COMP) 4-13 Fast Fourier Transform
H1(1) = x(1) – x(5) = 1.2 – (– 0.2) = 1.4 X(k) = {0, – j3.98, – 2j, j0.02, 0 – j0.02, j2, j0.398}
ge
H2(1) = x(3)–x(7) = 0.2 – (– 1.2) = 1.4 (i) Find DFT of x1(n) using any of the FFT technique
(ii) Let x2(n) = {5, 6, 7, 8, 1, 2, 3, 4}
Stage 2
io led
Using appropriate DFT property and answer of earlier
F1(0) = G1 (0) + W40G2 (0) = 0 + 1 · (0) = 0 part determine X2(k)
F2(0) = H1 (0) + W40H2 (0) = 1 + 1(– 1) = 0 DIT-FFT Butterfly diagram. The input is in the bit reversed
order.
F2(1) = H1 (1) + W41H2 (1)
Te
x1(n) = { 1 2 3 4 5 6 7 8 }
x(0)x(1)x(2)x(3)x(4)x(5)x(6)x(7)
= 1.4 + (– j) (1.4) = 1.4 – j1.4
Here, W04 =1
F2(2) = H1 (0) – W04H2 (0) –j2
W14 = e 4
= cos – j sin = – j
2 2
= 1 – 1(– 1) = 2
Similarly,
F2(3) = H1 (1) – W14H2 (1) W08 = 1
–j2· 1
= 1.4 – (– j) (1.4) = 1.4 + j1.4
W18 = e 8
= cos – j sin = 0.707 – j 0.707
4 4
Stage 3 –j2· 2
W28 = e 8
= cos – j sin = – j
X(0) = F1(0) + W08F2 (0) = 0 + 1 · (0) = 0 2 2
–j2· 3
X(1) = F1(1) + W18F2(1) 3 3
W38 = e 8
= cos – j sin
4 4
= – j2 + (0.707 – j0.707) (1.4– j1.4) = – j3.98 = – 0.707 – j 0.707
X(2) = F1(2) + W28F2(2) = 0 + (– j) (2) = – j 2 We write down the equations at each stage and calculate
the outputs.
X(3) = F1(3) + W38F2(3)
ge
io led Fig. P. 4.4.6
Stage 1 Stage 3
F2(0) = H1(0) + W40H2(0) = 8 + 1 · (12) = 20 (ii) Compute the DFT of x2(n) using appropriate DFT
property.
F2(1) = H1(1) + W41H2(1) = – 4 + (– j)(– 12) = – 4 + j12
Here, x1 (n) = { 1, 2, 3, 4, 5, 6, 7, 8 }
F2(2) = H1(0) – W04H2(0) = 8 – 1 · (12) = – 4 and x2 (n) = { 5, 6, 7, 8, 1, 2, 3, 4 }
F2(3) = H1(1) – W14H2(1) = – 4 – (– j) (– 12) = – 4 – j12 Imagine x1(n) and x2(n) to lie on 2 circles.
DSIP (MU-Sem. 7-COMP) 4-15 Fast Fourier Transform
Fig. P. 4.4.6(a)
ge
From the time shifting property of the DFT we know, We use the linearity property which is as follows then
DFT DFT
If x(n) X(k) If x (n) X (k)
io led
N
DFT
DFT
– j2km ax1(n) + b x2(n) a X1(k) + b X2(k)
Then x((n – m))N e X(k)
N Since,x3(n) = x1(n) + x2(n)
ic ow
= e X1(k)
X3 (0) = X1(0) + X2(0) = 36 + 36 = 72
Since the delay is of 4 units, m = 4, N = 8.
X3(1) = X1(1) + X2(1) = (– 4 + j9.65) + (– 4 – j 9.65)
at
Pu ch
We can write
– j2·k = 0
X2(k) = e X1 (k) X3(2) = X1(2) + X2(2) = (– 4 + j4) + (– 4 – j 4)
Te
Fig. P. 4.4.7
–j2
Stage 1 1 4
·1
W4 = e = cos – j sin = – j
G1(0) = x(0) + x(2) = 1 + 3 = 4 2 2
ge
G1(1) = x(0) – x(2) = 1 – 3 = – 2
G1(2) = x(1) + x(3) = 2 + 4 = 6
io led
G1(3) = x(1) – x(3) = 2 – 4 = – 2
Stage 2
ic ow
= – 2 + j2
X(2) = G1(0) – W04G1(2) = 4 – 1 (6) = – 2 Fig. P. 4.4.8
at
Pu ch
Fig. P. 4.4.10
Stage 1
ge
G1(1) = x(0) – x(2) = 0 – 2 = – 2
Fig. P. 4.4.9
io led G1(2) = x(2) + x(3) = 1 + 3 = 4
G1(3) = x(1) – x(3) = 1 – 3 = – 2
Stage 1
G1(0) = x(0) + x(2) = 1 + 3 = 4 Stage 2
0
ic ow
= – 2 + (– j) (– 2) = – 2 + j2
Stage 2 0
X (2) = G1 (0) + W4 G1 (2) = 2 – 1 (4) = – 2
at
W04
Pu ch
–j2 nk
·0 X(k) = x(n) WN
W04 = e 4
= 1 n=0
–j2
·1 N
W14 = e 4
= cos – j sin = – j 2 –1 N–1
2 2
nk nk
X(k) = x(n) WN + x(n) WN
We draw a 4-points DIT – FFT Butterfly
n=0 N
n = 2
DSIP (MU-Sem. 7-COMP) 4-18 Fast Fourier Transform
N N
In the second sum, put n = n + 2 –1
2
x(n) – x n + 2 WN
N (2k + 1)n
N N X(2k + 1) =
2 –1 2 –1 n=0
+ x n + WN
N
nk (n + N/2) k
X(k) = x(n) WN
2 ( ··· (– 1)2k + 1 = – 1)
n=0 n=0 2 1
N N Now WN = WN/2
2 –1 2 –1
N
x n + 2 WN WN WN
N
nk nk nk kN/2
= x(n) WN + 2 –1
ge
WN = (– 1)k
n=0
N N N
–1 2 –1 ; k = 0,1,2, … – 1…(4.5.2)
2
2
io led
x n +
N nk
nk
= x (n) WN + (– 1)k W
2 N
Let g1(n) = x(n) + x n + N
n=0
n=0 2
N x(n) – x n + N W n
ic ow
and g2(n) =
2 –1 2 N
x(n) + (– 1)k x n + 2 WN
N nk
X(k) = N
n
n=0 2 –1
bl kn
nk
We now split X(k) into odd and even parts, X(2k) = g1(n) WN/2 …(4.5.3)
n=0
N
at
2 –1 N
Pu ch
2 –1
(2k) = x(n) + x n + N W2nk ( ··· (– 1)2k = + 1 )
2 N and X (2k + 1) =
nk
g2 (n) WN/2 …(4.5.4)
n=0
Te
n=0
Fig. 4.5.1
DSIP (MU-Sem. 7-COMP) 4-19 Fast Fourier Transform
As is evident, the order of the input is retained but the N
4 –1
output is shuffled.
g1(n) + (– 1)k g1 n + 2 WN/2
N nk
Equations (4.5.3) and (4.5.4) represent two N/2 point X(2k) =
DFT’s. Since N = 8, these two equations represent two n=0
4-point DFT’s. Splitting X(2k) into odd and even parts we get,
Each of these can be further split up into two - 2 point N
DFT’s. We will do just that, 4 –1
ge
k = 0, 1, … – 1 …(4.5.6)
N N 4
4 –1 4 –1
g1 n +
N nk We also split X(2K + 1) into two N/4 point DFTs. Using
nk kN/4
= g1(n) WN/2
io led
+ WN/2
W
4 N/2
n=0 n=0
Equations (4.5.5) and (4.5.6), we draw the signal flow
kN/4 graph.
Now, WN/2 = (– 1)k
ic ow
N N
4 –1 4 –1
g1 n +
N nk
nk
g1(n) WN/2 + (– 1)k
n
X(2k) = W
4 N/2
bl kn
n=0 n=0
at
Pu ch
Te
Fig. 4.5.2
Fig. 4.5.3
DSIP (MU-Sem. 7-COMP) 4-20 Fast Fourier Transform
The final 8-point DIF-FFT signal flow graph is shown in Fig. 4.5.4.
ge
io led
Fig. 4.5.4 : 8-point DIF-FFT Butterfly diagram
In the DIF-FFT, the output is in the bit reversed format while the input is unaltered.
ic ow
The number of computations required by the DIT-FFT and the DIF-FFT are the same.
As stated earlier, FFT refers to a class of algorithms for efficiently computing the DFT. Hence FFT is not an
n
approximation of the DFT. It is the DFT with a reduced number of computations.
bl kn
Ex. 4.5.1 : A 8-Point sequence x(n) is given by {1, 2, 3, 2, 1, 5, 2, 1} find the DFT of the sequence using DIF-FFT.
Soln. : x(n)={1, 2,3, 2, 1, 5, 2, 1}
Te
Since N = 8 we draw a 8-point DIF-FFT Butterfly diagram. Remember the input is ordered but the output obtained is
in bit reversed order.
Fig. P. 4.5.1
DSIP (MU-Sem. 7-COMP) 4-21 Fast Fourier Transform
–j2
g2(1) = [x(1) – x(5)] W18
Here W04 = e 4
= cos 0 – j sin 0 = 1
–j2 = [2 – 5] (0.707 – j0.707) = – 2.12 + j2.12
W14 = e 4
= cos – j sin = – j g2(2) = [x(2) – x(6)] W28= [3 – 2] (– j) = – j
2 2
Similarly, g2(3) = [x(3) – x(7)] W38
–j2
·0 = [2 – 1] (– 0.707 – j0.707) = – 0.707 – j0.707
W08 = e 8
= cos 0 – j sin 0 = 1
Stage 2
–j2
·1 f1(0) = g1 (0) + g1 (2) = 2 + 5 = 7
W18 = e 8
= cos – j sin = 0.707 – j 0.707
4 4
–j2 f1 (1) = g1 (1) + g1 (3) = 7 + 3 = 10
·2
W28 = e 8
= cos – j sin = – j f2(0) = [g1 (0) – g1 (2)] W04 = [2 – 5] (1) = – 3
2 2
–j2
·3 3 3 f2(1) = [g1 (1) – g1 (3)] W14= [7 – 3] (– j) = – 4 j
W38 = e 8
= cos – j sin = – 0707 – j0.707
4 4
f3(0) = g2 (0) + g2 (2) = 0 + (– j) = – j
ge
Stage 1
f3(1) = g2 (1) + g2 (3)
g1(0) = x(0) + x(4) = 1 + 1 = 2
= (– 2.12 + j2.12) + (– 0.707 – j0.707)
g1(1) = x(1) + x(5) = 2 + 5 = 7
io led
= – 2.827 + j1.413
g1(2) = x(2) + x(6) = 3 + 2 = 5
f4(0) = [g2 (0) – g2 (2)]W04= 0 – (– j)
g1(3) = x(3) + x(7) = 2 + 1 = 3
ic ow
= 0 – (– j) (1) = + j
g2(0) = [x(0) – x(4)] W08= [1 – 1] (1) = 0
f4(1) = [g2(1) – g2 (3)]W14
n
bl kn
Stage 3
X(0) = f1(0) + f1(1) = 7 + 10 = 17
Te
= 2.827 + 2.413
X(7) = f4(0) – f4(1) = j – (2827 + j1413)
= 2.827 – j0.413
We now rearrange the output in the proper order
X(k) = {17, – 2.827 + j 0.413, – 3 – 4j, 2.827
+ j2.413, – 3, 2.827 – j2.413, – 3 + 4j, – 2.827 – j0.413}
Ex. 4.5.2 : Find 8-point DFT using Radix – 2 – DIF FFT algorithms for a given sequences
x(n) = {–1, 0, 2, 0, – 4, 0, 2, 0}
Soln. :
x(n) = { – 1, 0 , 2 , 0 , – 4, 0 , 2 , 0 }
x(0) x(1) x(2) x(3) x(4) x(5) x(6) x(7)
DSIP (MU-Sem. 7-COMP) 4-22 Fast Fourier Transform
We draw a 8-point DIF-FFT Butterfly diagram,
ge
io led
ic ow
Fig. P. 4.5.2
·0 Stage 2
W04 = e 4
= cos 0 – j sin 0 = 1
f1(0) = g1 (0) + g1 (2) = – 5 + 4 = – 1
–j2
at
·1
Pu ch
W14 = e 4
= cos – j sin = – j f1 (1) = g1 (1) + g1 (3) = 0 + 0 = 0
2 2
Similarly, f2(0) = [g1 (0) – g1 (2)] W04 = [– 5 – 4] (1) = – 9
Te
–j2
·0 f2(1) = [g1 (1) – g1 (3)] W14 = [0 – 0] (– j) = 0
W08 = e 8
= cos 0 – j sin 0 = 1
f3(0) = g2 (0) + g2 (2) = 3 + 0 = 3
–j2
·1
W18 = e 8
= cos – j sin = 0.707 – j0.707 f3(1) = g2 (1) + g2 (3) = 0 + 0 = 0
4 4
–j2 f4(0) = [g2 (0) – g2 (2)] W04 = [3 – 0] (1) = 3
·2
W28 = e 8
= cos – j sin = – j
2 2 f4(1) = [g2(1) – g2 (3)] W41 = [0 – 0] (– j) = 0
–j2
·3 3 3
W38 = e 8
= cos – j sin = – 0.707 – j 0.707 Stage 3
4 4
X(0) = f1(0) + f1(1) = – 1 + 0 = – 1
Stage 1
X(4) = f1(0) – f1(1) = – 1 – 0 = – 1
g1(0) = x(0) + x(4) = – 1 + (– 4) = – 5
X(2) = f2(0) + f2(1) = – 9 + 0 = – 9
g1(1) = x(1) + x(5) = 0 + 0 = 0
X(6) = f2(0) – f2(1) = – 9 – 0 = – 9
g1(2) = x(2) + x(6) = 2 + 2 = 4
X(1) = f3(0) + f3(1) = 3 + 0 = 3
g1(3) = x(3) + x(7) = 0 + 0 = 0
X(5) = f3(0) – f3(1) = 3 – 0 = 3
g2(0) = [x(0) – x(4)] W08 = [– 1 – (– 4)] (1) = 3
X(3) = f4(0) + f4(1) = 3 + 0 = 3
g2(1) = [x(1) – x(5)] W18
X(7) = f4(0) – f4(1) = 3 – 0 = 3
= [0 – 0] (0.707 – j0.707) = 0
We now arrange the output in the proper order
g2(2) = [x(2) – x(6)] W28 = [2 – 2] (– j) = 0
X(k) = { – 1, 3, – 9, 3, – 1, 3, – 9, 3 }
DSIP (MU-Sem. 7-COMP) 4-23 Fast Fourier Transform
Ex. 4.5.3 : Given x(n) = n + 1 and N = 8, find DFT X(k) using DIF-FFT algorithm.
Soln. :
Given : x(n) = n + 1 ; 0 n 7 (˙.˙ N = 8)
x(n) = {1, 2, 3, 4, 5, 6, 7, 8}
We draw a 8 – point DIF-FFT Butterfly diagram. In DIF-FFT, the input is ordered but the output obtained is in bit
reversed order.
–j2
·0
Here W04 = e 4
= cos 0 – j sin 0 = 1
–j2
·1
W14 = e 4
= cos – j sin = – j
2 2
–j2
·0
Similarly, W08 = e 8
= cos 0 – j sin 0 = 1
–j2
ge
·1
W18 = e 8
= cos – j sin = 0.707 – j 0.707
4 4
–j2
·2
W28 = e 8
io led = cos
2
– j sin = – j
2
–j2
·3 3 3
W38 = e 8
= cos – j sin = – 0.707 – j 0.707
4 4
ic ow
n
bl kn
at
Pu ch
Te
Fig. P. 4.5.3
ge
We now rearrange the output in the proper order
f4(1) = [g2(1) – g2(3)]W14
X(k) = { 36, – 4 + j9.66, – 4 + 4j, – 4 + 1.66j, – 4,
= (– 2.83 + j2.83) (2.83 + j2.83) (– j) = j5.66
io led – 4 – j1.66, – 4 – 4 j, – 4 – j9.66}
Stage 3
X(0) = f1(0) + f1(1) = 16 + 20 = 36
ic ow
Ex. 4.5.4 : Compute DFT of sequence x(n) = {1, 2, 2, 2, 1, 0, 0, 0} using DIF-FFT algorithm. Sketch its magnitude
spectrum.
n
bl kn
at
Pu ch
Te
Fig. P. 4.5.4
Soln. :
x(n) = {1, 2, 2, 2, 1, 0, 0, 0}
We draw a 8-point DIF-FFT Butterfly diagram in DIF-FFT, the input is ordered but the output obtained in bit reversed
order.
DSIP (MU-Sem. 7-COMP) 4-25 Fast Fourier Transform
ge
= cos – j sin = – 0.707 – j0.707
4 4
X(7) = f4(0) – f4(1) = j2 – (– j2.83) = j4.83
Stage 1
io led We now rearrange the output in the proper order.
g1(0) = x(0) + x(4) = 1 + 1 = 2
X(k) = {8, – j4.83, 0, – j0.83, 0, + j0.83, 0, j4.83}
g1(1) = x(1) + x(5) = 2 + 0 = 2
To sketch the magnitude spectrum. We compute the
ic ow
= 1.414 – j1.414
g2(2) = [x(2) – x(6)] W82 = [2 – 0] (– j) = – 2j
Te
= 1.414 – j1.414
Stage 2 Fig. P. 4.5.4(a)
f1(0) = g1(0) + g1(2) = 2 + 2 = 4 We observer that the magnitude spectrum is symmetric
f1(1) = g1(1) + g1(3) = 2 + 2 = 4
about the point, in this case 4.
2
f2(0) = [g1(0) – g1(2)] W04 = [2 – 2] (1) = 0
Ex. 4.5.5 : N = 8 point DFT using Radix FFT for the given
f2(1) = [g1(1) – g1(3)] W14 = [2 – 2] (– j) = 0 sequence x(n) = {1, 1, 1, 1, 0, 0, 0, 0}
ge
io led
Fig. P. 4.5.5
ic ow
–j2
·0 g2(3) = [x(3) – x(7)] W38
W04 = e 4
= cos 0 – j sin 0 = 1
= [1 – 0] (– 0.707 – j0.707)
at
–j2
·1
Pu ch
W14 = e 4
= cos – j sin = – j = – 0.707 – j0.707
2 2
Stage 2
Similarly,
Te
ge
= e = cos – j sin = – j
2 2
If x1(n) = x(– n), find x1(k) using earlier solution and not
–j2
·3 3 3
otherwise. W38 = e 8
= cos – j sin = – 0.707 – j0.707
io led 4 4
ic ow
n
bl kn
at
Pu ch
Te
Fig. P. 4.5.6
Stage 1
g1(0) = x(0) + x(4) = 1 + 4 = 5
g1(1) = x(1) + x(5) = 2 + 2 = 4
g1(2) = x(2) + x(6) = 1 + 1 = 2
g1(3) = x(3) + x(7) = 2 + 2 = 4
g2 (0) = [x(0) – x(4)] W08= [1 – 4] (1) = – 3
g2 (1) = [x(1) – x(5)] W18= [2 – 2] (0.707 – j0.707) = 0
g2 (2) = [x(2) – x(6)] W28= [1 – 1] (– j) = 0
g2 (3) = [x(3) – x(7)] W38= [2 – 2] (– 0.707 – j0.707) = 0
DSIP (MU-Sem. 7-COMP) 4-28 Fast Fourier Transform
Stage 3
ge
X(0) = f1(0) + f1(1) = 7 + 8 = 15
X(4) = f1(0) – f1(1) = 7 – 8 = – 1
io led
X(2) = f2(0) + f2(1) = 3 + 0 = 3
Fig. P. 4.5.7
X(6) = f2(0) – f2(1) = 3 – 0 = 3
Stage 1
ic ow
Stage 2
We now rearrange the output in the proper order.
X(0) = g1(0) + g1(1) = 6 + 8 = 14
X(k) = {15, – 3, 3, – 3, – 1, – 3, – 3, 3, – 3}
X(2) = g1(0) – g1(1) = 6 – 8 = – 2
Te
x(3) = cos = 0
3
x(n) = 2(n) + 3(n – 1) + 4(n – 2) + 5(n – 3)
2
Use DIF-FFT
x(n) = {1, 0, – 1, 0}
Soln. : Here (n) is a impulse functions while (n – 1),
(n – 2) and (n – 3) are impulse shifted to the right.
x(n) = {2, 3, 4, 5}
DSIP (MU-Sem. 7-COMP) 4-29 Fast Fourier Transform
ge
= cos – j sin = – j –j2
2 2 1 ·1
W4 = e 4 = cos – j sin = – j
Stage 1
io led 2 2
g1(0) = x(0) + x(2) = 1 – 1 = 0 Stage 1
g1(1) = x(1) + x(3) = 0 + 0 = 0 g1(0) = x(0) + x(2) = (1 + 2j) + (5 + 6j) = 6 + j8
ic ow
g1(2) = [x(0) – x(2)] W04 = [1 – (– 1)] (1) = 2 g1(1) = x(1) + x(3) = (3 + j4) + (7 + j8) = 10 + j12
g2(2) = [x(0) – x(2)] W40= [(1 + 2j) – (5 + 6j)] (1)
g1(3) = [x1(1) – x(3)] W14 = [0 – 0] (– j) = 0
n
bl kn
= – 4 – j4
Stage 2
X(0) = g1(0) + g1(1) = 0 + 0 = 0 g1(3) = [x(1) – x(3)] W81
at
Pu ch
Fig. P. 4.5.9
Stage 2
X(0) = g1(0) + g1(1) = (6 + j8) + (10 + j12) = 16 + j20
X(2) = g1(0) – g1(1) – (6 + j8) – (10 – j12) = – 4 – j4
X(1) = g1(2) + g1(3) = (– 4 – j4) + (– 4 + j4) = – 8
X(3) = g1(2) – g1(3) = (– 4 – j4) + (– 4 + j4) = – j8
ge
Total number of stages are log2 N and at each stage, 2
additions.
butterflies are required. For each butterfly, ‘2’
2. Computations required using FFT algorithm
io led complex additions are required.
We begin by calculating the computation complexity
N
Total complex additions = 2 log2 N
2
required for one butterfly. Consider the general
ic ow
For a 8 point DFT, 4 butterflies are required at each The Table 4.6.1 shows that, by the use of FFT
'N' algorithms the number of complex multiplications and
stage. So for ‘N’ point DFT, at each stage, 2
complex additions are reduced. `So there is tremendous
butterflies are required. improvement in the speed
DSIP (MU-Sem. 7-COMP) 4-31 Fast Fourier Transform
4.6.1 Solved Examples on Computation of
Inverse DFT using FFT Algorithms
Soln. :
Here, N = 16
Using DFT
Fig. P. 4.6.2
Number of multiplications = N2 = 162 = 256
Number of addition = N(N – 1) = 16 15 = 240 Ex. 4.6.3 : Find the I-DFT using DIT-FFT of the given
Using FFT example.
N X(k) = {10, – 2 + 2j, – 2, – 2 – 2j }
Number of Multiplication = logN = 32
2 2
Soln. :
ge
Number of Addition = N logN
2
= 64
N–1
X(k) = x(n) Wnk
N ...(1)
n
k=0
bl kn
Fig. P. 4.6.3
The 1-D-IDFT formula is
N–1 y(0) = X(0) + X(2) = 8
at
1
Pu ch
WN* nk
y(1) = X(0) – X(2) = 12
x(n) = X(k) ...(2)
N
k=0
y(2) = X(1) + X(3) = – 4
Te
ge
–j2
g2(1) = X*[(1) – X*(5)] W18
·0
W08 = e 8
= cos 0 – j sin 0 = 1
io led = [(– 4 – j9.656) – (– 4 + j 1.651)] (0.707 – j0.707)
–j2
·1 = –8–j8
W18 = e 8
= cos – j sin = 0.707 – j 0.707
4 4 g2(2) = [ X*[(2) – X*(6)] W82
–j2
·2
ic ow
W28 = e 8
=cos – j sin = – j = [(– 4 – j4) – (– 4 + j 4)] (– j)] = – 8
2 2
–j2
g2(3) = X*[(3) – X*(7)] W38
·3 3 3
n
W38 = e 8
=cos – j sin = [(– 4 –j1.656) – (– 4 + j9.656)] (– 0.707 – 0.707)
4 4
bl kn
= – 0.707 – j 0.707 = – 8 + j8
at
Fig. P. 4.6.4
DSIP (MU-Sem. 7-COMP) 4-33 Fast Fourier Transform
f1(1) = g1(1) + g1(3) = (– 8 – j8) + (– 8 + j8) x*(5) = [f3(0) – f3(1)]/8 = [32 – (– 16)]/8 =6
f2(0) = [g1(0) + g1(2)] W04= [32 – (– 8)](1) = 40 x*(7) = [f4(0) – f4(1)]/8 = [48 – (– 16)]/8 = 8
f2(1) = [g1(1) – g1(3)] W14 We rearrange the output in the proper order. Since x*(n)
values are all real
= [(– 8 –j8) – (– 8 + j8) ](– j) = – 16
x(n) = x* (n)
f3(0) = g2(0) + g2(2) = 40 + (– 8) = 32
x(n) = {1, 2, 3, 4, 5, 6, 7, 8}
f3(1) = g2(1) + g2(3) = (– 8 – j8) + (– 8 + j8)
Ex. 4.6.5 : Let x(n) be 8-point sequence. Its
= – 16 corresponding DFT X(k) is,
ge
f4(0) = [g2(0) – g2(2)]W04 = [40 – (– 8)] (1) = 48 X(k) = { 0.5, 2 + j, 3 + j2, j, 3, - j, 3 – j2, 2 – j }
f4(1) = [g2(1) – g2(3)]W14io led Soln. :
= [(– 8 – j8) – (– 8 + 8)](– j) = – 16 We will use the DIT – FFT algorithms since N = 8, we use
Stage 3 the DIT – FFT algorithms we give X*(k) as the input and
divide the output obtained by N. We also take the complex
ic ow
Fig. P. 4.6.5
Here, W04 = 1
–j2
·1
W14 = e 4
= cos – j sin = – j
2 2
Similarly, W08 = 1
–j2
·1
W18 = e 8
= cos – j sin = 0.707 – j0.707
4 4
DSIP (MU-Sem. 7-COMP) 4-34 Fast Fourier Transform
–j2
·2 F2(3) = H1(1) – W14 H2 (1)
W28 = e 8
= cos – j sin = – j
2 2
–j2 = (2 – j2) – (– j) (– 2 – j2)
·3 3 3
W38 = e 8
= cos – j sin = – 0.707 – j 0.707 = 4 – j4
4 4
We write down the equation at each stage and Stage 3
calculate the outputs x*(0) = [F1(0) + W08 F2(0)] /8 = [9.5 + (1) 4] /8 = 1.69
Stage 1
x*(1) = [F1(1) + W18 F2(1)] /8
G1(0) = X*(0) + X*(4)
= [– 6.5 + (0.707 – j0.707 (0)] /8 = – 0.81
= 0.5 + 3 = 3.5 x*(2) = [F1(2) + W28 F2(2)] /8
G1(1) = X*(0) – X*(4)
= [– 2.5 + (– j) (0)] /8 = – 0.31
= 0.5 – 3 = – 2.5 x*(3) = [F1(3) + W38 F2(3)] /8
ge
G2(0) = X*(2) + X*(6)
= [1.5 + (– 0.707 – j0.707) (4 – j4) ]/8 = – 0.52
= (3 – j2) + (3 + j2) = 6
x*(4) = [F1(0) – W08 F2(0)] /8 = [9.5 – (1) 4] /8 = 0.69
io led
G2(1) = X*(2) – X*(6)
x*(5) = [F1(1) – W18 F2(1)] /8
= (3 – j2) – (3 + j2) – j4
= [– 6.5 – (0.707 – j0.707) (0)]/8 = – 0.81
ic ow
Stage 2
F1(0) = G1(0) + W04 G2(0) x(n) ={1.69, – 0.81,– 0.31, – 0.52, 0.69,
= 2 + (1) (2) = 4 {X(0), X(1), X(2), X(3), X(4), X(5), X(6), X(7)}
ge Fig. P. 4.6.6
io led
Similarly, F1(1) = G1(1) + W14 G2 (1)
W08 = 1
ic ow
= – j6 + [(– j) (2 + j14)] = 14 – j8
–j2
·1
W18 = e 8
= cos – j sin F1(2) = G1(0) – W04G2(0)
n
4 4
bl kn
8
= cos – j sin = – j
Pu ch
2 2
–j2
·3 3 3 = – j6 – [(– j) (2 + j14)] = – 14 – j4
W38 = e 8
= cos – j sin
Te
4 4
F2(0) = H1(0) + W04H2(0)
= –0.707 – j 0.707
We write down the equation at each stage and = (2 – j2) + [(1) (– j6)] = 2 – j8
calculate the outputs. F2(1) = H1(1) + W14 H2 (1)
Stage 1
G1(0) = X*(0) + X*(4) = 4 + j6 = (– 2 + j14) + [(– j)(– j6)]
Stage 2 Stage 3
x*(3) = [F1(3) + W38F2(3)] /N = [(– 14 – j4) = [(2 + j4) – [(– j) (2 + j4)]]/8 = – 0.25 + j0.75
ge
x*(n) = {1, 2.28 + j0.95, 0.75 + j0.25, – 0.86 – j2.09, 0.5 + j2, 1.22 – j2.94, – 0.25 + j0.75, – 2.63 + j1.09}
Ex. 4.6.7 : Find IDFT of X(k) = {10, – 2 + 2j, – 2, – 2 – 2j} using DIT-FFT algorithm.
Soln. :
n
bl kn
Fig. P. 4.6.7
Here, W40 = 1
W14 = –j
Stage 1
G1(0) = X*(0) + X*(2) = 10 + (– 2) = 8
G1(1) = X*(1) – X*(2) = 10 – (– 2) = 12
G1(2) = X*(1) + X*(3) = (– 2 – j2) + (– 2 + j2) = – 4
G1(3) = X*(1) – X*(3) = (– 2 – j2) – (– 2 + j2) = – j4
DSIP (MU-Sem. 7-COMP) 4-37 Fast Fourier Transform
Stage 2 –j2
4 ·0
x*(0) = [G1(0) + W04G1(2)] /4 Here, W40 = e = cos 0 – j sin 0 = 1
–j2
= [8 + (1) (– 4)]/4 = 1 4 ·1
W14 = e = cos – j sin = – j
2 2
x*(1) = [G1(1) + W14G1(3)] /4
Stage 1
= [12 + (– j) (– j4)]/4 = 2
G1(0) = x(0) + x(2) = 1 + 1 = 2
x*(2) = [G1(0) – W04G1(2)] /4 = [8 – (1) (– 4)]/4 = 3
G1(1) = x(0) – x(2) = 1 – 1 = 0
x*(3) = [G1(1) – W14G1(3)] /4 G1(2) = x(1) + x(3) = 2 + 4 = 6
= [12 – (– j) (– j4)]/4 = 4 G1(3) = x(1) – x(3) = 2 – 4 = – 2
x*(n) = {1, 2, 3, 4}
Stage 2
x(n) = {1, 2, 3, 4}
X(0) = G1(0) + W04G1(2) = 2 + (1) (6) = 8
4.6.2 Filtering using FFT Algorithms X(1) = G1(1) + W14G1(3) = 0 + (– j) (– 2) = j2
ge
Ex. 4.6.8 : Determine circular convolution of X(2) = G1(0) – W04G1(2) = 2 – (1) (6) = – 4
x(n) = {1, 2, 1, 4} and h(n) = {1, 2, 3, 2} using Radix-2 - FFT.
io led X(3) = G1(1) – W14G1(3) = 0 – (– j) (– 2) = – j2
Soln. : From the circular convolution property of the DFT,
X(k) = {8, j2, – 4, – j2}
it is known than,
ic ow
DFT Step 2 : In a similar manner we compute
h(n)
y(n) = x(n) O X(k) H(k) = Y(k)
IDFT the DFT of h(n)
n
Hence to determine circular convolution using DFT, we
bl kn
Stage 2
H1(0) = G1(0) + W04G1(2) = 4 + (1) (4) = 8
H1(1) = G1(1) + W14G1(3) = – 2 + (– j) (0)
= –2
H1(2) = G1(0) – W04G1(2) = 4 – (1) (4) = 0
H1(3) = G1(1) – W14G1(3) = – 2 – (– j) (0)
= –2
Fig. P. 4.6.8
H(k) = {8, – 2, 0, – 2}
DSIP (MU-Sem. 7-COMP) 4-38 Fast Fourier Transform
Step 3 : y(n) = x(n) h(0)
Y(k) = X(k) · H(k) We generate a circular matrix of x(n)
Y(0) = X(0) · H(0) = (8) · (8) = 64
Y(1) = X(1) · H(1) = (j2) · (– 2) = – j4
Y(2) = X(2) · H(2) = (– 4) · (0) = 0
Y(3) = X(3) · H(3) = (– j2) (–2) = j4
Y(k) = {64, – j4, 0, j4}
Step 4 : y(n) = {16, 18, 16, 14}
The final step is to obtain y(n). This is done by Hence it is seen the results obtained are the same.
computing the IDFT of Y(k). We will use the DIT-FFT Ex. 4.6.9 : By means of FFT-IFFT technique, compute the
butterfly diagram with the required modification. linear convolution of x(n) = {2, 1, 2, 1},
h(n) = {1, 2, 3, 4}
ge
Soln. : We are supposed to compute linear convolution
using FFT-IFFT.
io led
We know from the circular convolution property that,
DFT
h(n)
y(n) = x(n) O X(k) · H(k) = y(k)
ic ow
IDFT
be N1 + N2 – 1.
Fig. P. 4.6.8(b)
In this case length x(n) and h(n) = 4.
at
Pu ch
Stage 1
G1(0) = y*(0) + y*(2) = 64 + 0 = 64 If x(n) and h(n) are made equal to (4 + 4 – 1) = 7,
then circular convolution and linear convolution will give us
Te
y(1) = [G1(1) + W14G1(3)]/4 In order to use the radix-2 algorithm, the lengths of
the signal must be powers of 2. We therefore pad one more
= [64 + (– j) (j8)]/4 = 18
zero to both x(n) and h(n) and make their lengths equal to 8.
y(2) = [G1(0) – W04G1(2)/4 = [64 – (1) (0)]/4 = 16
Once the final result is obtained, we shall delete the
y(3) = [G1(1) – W14G1(3)]/4 last value.
x(n) = {2, 1, 2, 1, 0, 0, 0}18
= [64 – (– j) (j8)/4 = 14
h(n) = {1, 2, 3, 4, 0, 0, 0, 0}18
y(n) = {16, 18, 16, 14}
Since y*(n) has all real values Steps involved are:
We would have obtained the same result had we 3. Obtain Y(k) = X(k) · H(k)
performed time domain circular convolution. Let us check 4. Compute IDFT of y(k) to obtain y(n)
the result.
DSIP (MU-Sem. 7-COMP) 4-39 Fast Fourier Transform
We shall use the DIT-FFT algorithm to compute the DFT of x(n) and h(n).
Step 1 :Computing X(k) from x(n)
X(n) = {2, 1, 2, 1, 0, 0, 0, 0} x(0) x(1) x(2) x(3) x(4) x(5) x(6) x(7)
Here W04 = 1
–j2
·1
W14 = e 4
= cos – j sin = – j
2 2
Similarly, W08 = 1
–j2
·1
W18 = e 8
= cos – j sin = 0.707 – j 0.707
4 4
–j2
·2
W28 = e 8
= cos – j sin = – j
2 2
–j2
·3 3 3
W38 8
ge
= e = cos – j sin = – 0.707 – j 0.707
4 4
We write down the equation at each stage and calculate the outputs.
io led
ic ow
n
bl kn
at
Pu ch
Te
Fig. P. 4.6.9
Stage 1 G1(0) = x(0) + x(4) = 2 + 0 = 2 F1(1) = G1(1) + W14 G2(1) = 2 +(– j) (2) = 2 – j2
G1(1) = x(0) – x(4) = 2 – 0 = 2 F1(2) = G1(0) – W04 G2(0) = 2 – (1) (2) = 0
G2(0) = x(2) + x(6) = 2 + 0 = 2 F1(3) = G1(1) – W14 G2(1) = 2 – (– j) (2) = 2 + j2
G2(1) = x(2) – x(6) = 2 – 0 = 2
F2(0) = H1(0) + W04 H2(0) = 1 + (1) (1) = 2
H1(0) = x(1) + x(5) = 1 + 0 = 1
F2(1) = H1(1) + W14 H2(1) = 1 + (– j) (1) = 1 – j1
H1(1) = x(1) – x(5) = 1 – 0 = 1
F2(2) = H1(0) – W04 H2(0) = 1 – (1) (1) = 0
H2(0) = x(3) + x(7) = 1 + 0 = 1
F2(3) = H1(1) – W14 H2(1) = 1 – (– j) (1) = 1 + j1
H2(1) = x(3) – x(7) = 1 – 0 = 1
Stage 3
Stage 2
X(0) = F1(0) + W80F2(0) = 4 + (1) (2) = 6
F1(0) = G1(0) + W04 G2(0) = 2 +(1) (2) = 4
X(1) = F1(1) + W81F2(1)
DSIP (MU-Sem. 7-COMP) 4-40 Fast Fourier Transform
ge
G2(1) = h(2) – h(6) = 3 – 0 = 3
X(6) = F1(2) – W28F2(2) = 0 – (j) (0) = 0
io led H1(0) = h(1) + h(5) = 2 + 0 = 2
X(7) = F1(3) – W38F2(3) H1(1) = h(1) – h(5) = 2 – 0 = 2
Fig. P.4.6.9(a)
ge
= (1 – j3) – [(0.707 – j0.707) (2 – j4)]
= 2.41 + j1.24
io led Fig. P.4.6.9(b)
H(6) = F1(2) – W28F2(2) = – 2 – [(– j) (– 2)]
y(n) = {2, 5, 10, 16, 12, 11, 4}
= – 2 – j2
Hence it is seen that the results obtained one the same.
ic ow
H(k) = {10, – 0.41 – j7.24, – 2 + j2, In this chapter we study the algorithms proposed by
Cooley and Tukey. This method came to be known as the
at
Y(0) = X(0) · H(0) = 60 decimation in Frequency for Radix 2 were derived. We also
learnt how to use the butterfly diagram to compute the
Y(1) = X(1) · H(1) = – 25.55 – j13.07
Inverse DFT. Many examples were solved to understand
Y(2) = X(2) · H(2) = 0 how to compute the DFT using the FFT. Filtering using the
Y(3) = X(3) · H(3) = 5.55 – j1.07 FFT algorithms were also carried out.
Y(4) = X(4) · H(4) = – 4
Y(5) = X(5) · H(5) = 5.55 + j1.07 Review Questions
Y(6) = X(6) · H(6) = 0
Q. 1 Draw basic butterfly structure for DIT- FFT.
Y(7) = X(7) · H(7) = – 25.55 + j13.07
Q. 2 Draw total signal flow graph for DIT-FFT.
Y(k) = {60, – 25.55 – j13.07, 0,
Q. 3 Obtain computational complexity of FFT
5.55 – j1.07, – 4, 5.55 + j 1.07, 0, algorithm.
– 25.55 + j13.07} Q. 4 Explain in place computation of FFT.
Step 4: Compute IDFT of y(k) to obtain y(n) we use the Q. 5 Derive the first stage of DIF-FFT algorithm.
DIT–FFT algorithm to compute the IDFT. The final output Draw the basic butterfly structure for the same.
obtained after computing the IDFT is, Q. 6 Compare DIT-FFT and DIF-FFT algorithms.
y(n) = {2, 5, 10, 16, 12, 11, 4, 0} Q. 7 Write a short note on bit reversal in FFT.
Since an extra zero was added to x(n) and h(n) to
increase their lengths to 8, we remove the last zero of y(n).
5 Introduction to Image Processing
Syllabus
Introduction to Digital Image, Digital Image Processing System, Image File Formats: BMP, TIFF and JPEG.
ge
Of the five senses that human beings have, sight is what we the tribe. Refer Fig. 5.2.1.
depend upon the most. Not many animals depend on their
This art developed through the ages by way of
visual systems; the way human beings do.
materials and skill. By the mid-nineteenth century,
io led
Bats use high frequency sound waves. They emit
photography was well established. Image processing
sound waves which reflect back when they encounter some
that we study starts from this era.
obstruction. Cats have poor vision but an excellent sense of
ic ow
Processing ?
at
Pu ch
Fig. 5.3.3
Fig. 5.3.1
ge
In moving from the 3-dimensional world to the
2-dimensional image, we loose one dimension. Depth
information is lost. As can be seen from the Fig. 5.3.1,
io led
the handle of the tea cup is missing.
All family pictures, photographs on identity cards etc.
are 2-dimensional. If this statement is not clear, let us
ic ow
familiar with a signal of this kind. Here the voltage is In this case, to locate the dot shown, we need to know
varying with respect to time. This is a typical its position in two directions (x and y) Fig. 5.3.4. Hence
at
Pu ch
1-dimensional signal. If we want to locate a dot on the all images that we see are 2-dimensional functions. A
wave, all we need to know is its corresponding time. typical image is represented as shown in Fig. 5.3.4.
Here (x1, y1) are the spatial coordinates and f is the
Te
Fig. 5.3.2
Fig. 5.3.5
DSIP (MU-Sem. 7-COMP) 5-3 Introduction to Image Processing
ge
io led Fig. 5.4.1
These two forms of the same energy are transmitted Ex. 5.4.1 : Calculate the frequency of oscillation of green
light.
n
together as electromagnetic radiation. One cannot
Soln. :
bl kn
–9
propagated outwards from its source at a velocity of (500 10 m)
8
300,00,0000 meters per second (3 10 m/sec). Its frequency of oscillations can be calculated using
Te
Note : A black body radiator is one that absorbs all the If we want an infra-red image, we use cameras which
radiation incident upon it and has no reflecting power. The
are sensitive to infra-red radiations. For normal images
(family pictures etc.) we use cameras which are
radiation from a heated black body source is called black
sensitive to the visual spectrum. In this book we shall
body radiation and is always quoted in Kelvin.
discuss cameras (sensors) which are sensitive only to
The unit is called candela because initially it was the visual range.
defined as a standard candle burning a specific amount of
Quantum detectors
wax per hour. There is another important unit apart from
Quantum detection is the most important mechanism
candela that we encounter. This unit is called lux.
of image sensing and acquisition. It relies upon the
5.6 Basic Elements/Steps of an Image energy of absorbed photons being used to promote
Processing System electrons from their stable state to a higher state
above an energy threshold.
MU - Dec. 2018
Whenever this occurs, the properties of that material
ge
Q. Explain Fundamental steps in Image processing. get altered in some measurable way. Planck/Einstein
(Dec. 2018, 5 Marks) came up with a relationship between the wavelength
of the incident photon and the energy that it carries.
io led
Digital image processing is basically modification of
images on a computer. The basic components of an image hc
e = …(5.6.1)
processing system are as follows :
ic ow
The front face of the signal plate is coated with SnO2 (tin oxide) which forms the conducting layer. This plate is biased
to a positive potential of about 50 V. The target coating is maintained at approximately 0 V by a mesh grid which is
placed behind it.
ge
io led
Fig. 5.6.2
Due to this the signal plate and target behave as a The biggest drawback of the vidicon tube is that it uses
ic ow
continuous array of capacitors containing a the concept of deflection coils to position the electron
photoconductive dielectric. beam. These deflection coils make the vidicon bulky
n
When there is no light incident on the target, its and are responsible for major power drain. Since the
bl kn
resistance is very high due to which the charge across coils are magnetic, the vidicon also becomes sensitive
the capacitor is maintained. However when light to external fields.
at
Pu ch
Fig. 5.6.3
ge
two-dimensional image, the line array CCD imager has to investigate static real world scenes without any
to be used as a scanning device by moving this array mechanical scanning. Thus much more information
io led
over the object by some mechanical activity. can be deduced from a single real time glance than
would be possible with line arrays.
Area arrays can be seen in all the digital cameras that
ic ow
complexity.
Area sensors come in different ranges. i.e. 256 256,
at
Pu ch
Fig. 5.6.4 All video signals are essentially in analog form i.e.
electrical signals convey luminance and colour with
This technique is used in flat bed scanners (the
continuously variable voltage. The cameras are
scanners that you come across in your laboratory or in interfaced to a computer where the processing
a cyber cafe). A line array CCD can have anything from algorithms are written.
a few elements to upto 6000 or more.
This is done by a frame grabber card. Usually a frame
(ii) Area Arrays : The problem with line arrays is that it grabber card is a Printed Circuit Board (PCB) fitted to
scans only one line. To get a two-dimensional image, the host computer with its analog entrance port
we need to mechanically move the array over the matching the impedance of the incoming video signal.
entire image. The A/D converter translates the video signals into
digital values and a digital image is constructed. Frame
grabber cards usually have a A/D card with resolution
of 8 - 12-bits (256 to 4096 gray levels). Hence a frame
grabber card is an interface between the camera and
the computer.
DSIP (MU-Sem. 7-COMP) 5-7 Introduction to Image Processing
Frame grabber card has a block of memory, separate from the computers own memory, large enough to hold any
image. This is known as the frame buffer memory. Image data, usually in the form of bytes (8-bits), is written into the
frame grabber memory under the computer control, usually by DMA transfers.
The contents of the memory are continuously read out at video rate (30 frames/sec), passed through the D/A
converter and displayed on the monitor.
The output has a colour map or a colour Look Up Table (LUT) to permit pseudo colouring. The table consists of 8-bit
values for each of the red, green and blue guns of the monitor.
The commercially available frame grabber cards have additional features such as ability to zoom regions of the image
and pan the images.
The frame buffer memory can be upto 5 MB. Images being 2-dimensional functions, occupy a lot of space and hence
the storage space on the host computer has to be large. Let us try to find out as to how much space is actually taken
by images.
ge
io led
ic ow
n
bl kn
at
Pu ch
Te
Fig. 5.6.7(b)
ge
computer RAM. Due to this, the frame buffer memory monitors and CRTs.
has become more or less obsolete. Only the very high
Any erasable raster graphics display can be used as a
io led
end frame grabber cards still have a small frame
display unit with an image processing system.
grabber memory embedded on them.
However monochrome and colour TV monitors are the
Images being two-dimensional functions, occupy a lot
principal display devices used in modern image
ic ow
Fig. 5.6.8
DSIP (MU-Sem. 7-COMP) 5-9 Introduction to Image Processing
The image sequence from the camera is coded into as 5.7 Image Types
concise a representation as possible for transmission
over the channel. Images are 2-dimensional functions, as shown in
Fig. 5.7.1.
Most transmission in broadcast television are still in
analog form and analog coding methods are used to
make it as efficient as possible. NTSE, PAL and SECAM
are the 3 major coding systems used in various parts of
the world (USA uses NTSE, while India uses PAL).
Digital image coding is a high activity area. In image
processing; it is concerned with efficient transmission
of images over digital communication channels. A
Fig. 5.7.1
variety of indigenous ideas have been developed in
recent years. Images can be classified as follows :
ge
Coding is influenced by the type of the channel used to
carry the image signals. Several different types of
transmission channels are encountered in practice
io led
including cables, terrestrial radio, satellites, and optical
fibres. After decoding at the receiver, the image
sequence is
ic ow
y = cx
Fig. 5.7.2 : Image Types
where, c = Constant
at
Pu ch
Fig. 5.7.3
(2) Grey Scale Image : Here each pixel is usually stored as
a byte (8-bits). Due to this, each pixel can have values
ranging from 0 (black) to 255(white). Grey scale
images, as the name suggests have black, white and
various shades of grey present in the image. Refer
Fig. 5.7.4.
Fig. 5.6.9
DSIP (MU-Sem. 7-COMP) 5-10 Introduction to Image Processing
new(x,y) = (a(x,y)+b(x,y)+c(x,y))/3;
new1(x,y) = 3*a(x,y)+0.59*b(x,y)+0.11*c(x,y);
end
end
figure(1)
imshow(uint 8(im))
figure(2)
imshow(uint 8(new))
figure(3)
Fig. 5.7.4
imshow(uint8(new1))
(3) Colour Image (24-bit)
Matlab has an inbuilt command for conversion
Colour images are based on the fact that a variety of rgb2gray.
ge
colours can be generated by mixing the three primary
(4) Half Toning
colours viz, Red, Green and Blue, in proper
It is obvious that a grey scale image definitely looks
io led
proportions. In colour images, each pixel is composed
of RGB values and each of these colours require 8-bits better than the monochrome image as it utilizes more
(one byte) for its representation. grey levels. But there is a problem in hand.
ic ow
Hence each pixel is represented by 24-bits [R(8-bits), Most of the printers that we use (inkjet, lasers, dot
G(8-bits), B(8-bits)]. matrix) are all bi-level devices. i.e., they have only a
n
A 24-bit colour image supports 16, 777, 216 different black cartridge and can only produce two levels (black
bl kn
ge
look at these squares from a distance, the two squares
give us a perception of 2 different grey levels. Fig. 5.7.8
io led
This integration property of the eye is the basis for half
toning. In this, we take a matrix of a fixed size and
depending on the grey level required, we fill the matrix
ic ow
illusion of 10 different grey levels when viewed from a It can be seen that it does not look like a grey level. It
distance. looks like a straight black line. Hence lines should be
at
Pu ch
Here, the first block represents white, the last block (ii) Generate the matrices starting from all white
represents black and all the other blocks represent pixels to all black pixels.
intermediate values of grey. So in this case, while (iii) Read the original image. For every grey level value
printing, if we encounter grey level 0, we plot 9 pixels read, plot the corresponding matrix.
which are all white. If we encounter grey level 1, we Remember, the physical size of the half-toned image
plot 9 pixels of which only one pixel is black and so on. will always be bigger than the original image as for
As is evident a 3 3 matrix will generate 10 different every single grey level value, we output an entire
grey levels. matrix.
DSIP (MU-Sem. 7-COMP) 5-12 Introduction to Image Processing
5.8 Image File Formats JPEG (Joint Photographic Expert Group) is the name of
the committee that developed an image format which
MU : May 2016, Dec. 2016
used compression algorithms.
Q. Explain in detail any two types of image file formats. JPEG images are compressed images which occupy
(May 2016, 8 Marks) very little space. It is based on the Discrete Cosine
Q. What are various file formats ? Explain each in brief. Transform-DCT (explained in chapter of Image
(Dec. 2016, 8 Marks) Transforms). JPEG images use lossy compression
algorithms which result in some loss of original data
Images obtained from the camera are stored on the
and hence the quality of JPEG images is not as good as
host computer using different formats. A file format is
BMP images.
a structure which defines how information is stored in
the file and how that information is displayed on the Although these formats differ in technical details, they
monitor. share structural similarities.
There are numerous image file formats which are The Fig. 5.8.1 shows the typical organisation of
ge
available. Of these only a few of them can be used information encoded in an image file.
universally. By universally it means, they can be The image file consists of two parts;
understood by different operating systems.
io led (1) Header
Some of the image formats that can be used on either (2) Image data
Macintosh or PC platforms are;
ic ow
By interlaced we mean that the RGB values of each From this value, we could find out the number of bits
pixel stay together consecutively followed by the three allocated for each pixel. For example, if the maximum
colour components for the next pixel i.e., allowable pixel value is 255 then we know that each
8
R G B R G B R G B …… bit is represented by 8 bits (2 = 256).
st nd Fig. 5.8.2 shows a 8 8 grey scale image and its
1 Pixel 2 Pixel ...........
representation as a ASCII PGM file
If the RGB values are not interlaced, the values of one
primary colour for all pixels appear first, then the
values of the next primary colour followed by the
values of the third primary colour. Thus the image data
is in the form.
R R R R........ G G G G.......... B B B B.......
The compression type in the header indicates whether
the image data is compressed using algorithms such as
ge
Run length encoding. Apart from these, there are a
few more formats which we come across while dealing
Fig. 5.8.2
with images.
io led
PGM (Portable Grey Map) PGM is used to represent
grey level images.
ic ow
Computer vision which is also known as Machine chapters. This chapter forms the fundamental base
vision deals with the analysis of image content. required to understand image processing. Image acquisition
Computer vision is used to automate a process. forms the first step in any image processing system. In this
chapter, a basic block diagram of the image processing
Table 5.9.1 system is introduced. Each block in the system is explained
in detail. Important devices such as Vidicon cameras, CCD
Output Image Description
cameras and the frame grabber card are explained using
Input (Mathematical function) simple illustrations. Importance of each is stated.
Applications of line array CCD’s and area array CCD’s are
Image I.P. C.V.
presented. Basic concepts of image formats are also
Description C. G. – explained.
(Mathematical function)
Review Questions
From the Table 5.9.1,
Image processing Input (Image) – Output (Image) Q. 1 What do we mean by image processing ?
ge
Computer graphics Input (Description) – Output (Image) Q. 2 Why do we say that an image is a 2D-function ?
Computer vision Input (Image) – Output (Description) Q. 3 Calculate the frequency of oscillation of red light.
io led
The material provided in this chapter is primarily basic Q. 4 Distinguish between image processing and graphics.
information which would be required in subsequent Q. 5 List the basic elements of an image processing
discussions. Our study of the human visual system, though system.
ic ow
not exhaustive, provides a basic idea of the capabilities of Q. 6 Explain working of a Vidicon camera.
the eye in perceiving pictorial information.
n
Q. 7 Explain line array and area array CCD cameras.
bl kn
Topics such as electromagnetic spectrum are discussed Q. 12 Explain the basics of quantum detector.
with examples. Q. 13 Explain gamma of a camera.
The concepts explained here will be found useful in Q. 14 How many grey levels will a half toned image have ?
understanding image processing algorithms in subsequent Explain in detail.
6 Sampling and Quantization
Syllabus :
Sampling and Quantization. Representation of Digital Image
6.2 Sampling
6.1 Introduction
We know that an image is basically a 2-dimensional MU - May 2012, May 2013, Dec. 2013.
ge
representation of the 3-dimensional world. We have Q. Write short note on : Sampling and Quantization.
also studied that images can be acquired using a
(May 2012, May 2013, Dec. 2013, 5 Marks)
io led
Vidicon or a CCD camera or using scanners.
The basic requirement for image processing is that Consider a band-limited signal. Although real world
images obtained be in the digital format. For example, signals are rarely band limited, we can produce one by
ic ow
one cannot work with or process photographs on passing the signal first through a low-pass filter known
identity cards unless he/she scans it using a scanner. as an anti-aliasing filter.
n
The scanner digitizes the photograph and stores it on
Note : A signal is said to be band limited, if its Fourier
bl kn
Pu ch
To cut a long story short, to perform image processing, impulses (g(t) is also known as a COMB function), then
we need to have the images on the computer. This
the convolution of the two is given by f(t) * g(t). Let us
will only be possible when we digitize the analog
see what happens when we convolve f(t) with g(t).
pictures.
Proof : We know that the convolution of f(t) and g(t) is
Now that we have understood the importance of
digitization, let us see what this term actually means.
The process of digitization involves two steps : y(t) = f() g(t – ) d = g() f(t – ) d
– –
y(t) = [(t – T) + (t) + (t + T)] f(t – )d
–
y(t) = (t – T) f(t – ) d + (t) f(t – ) d
– –
Fig. 6.1.1 : Steps of process of digitization
In other words, Digitization = Sampling + Quantization. + (t + T) f(t – ) d
We have had exposure to these terms in the lower –
semesters in subjects like Principles of Communication
Engineering, Signals and Systems and Signal Processing but, (t – T) f(t – ) d = (t – T) * f(t)
which dealt with 1-dimensional signals. Let us take a –
brief look at these concepts and move ahead to the [This is impulse at t = –T convolved with f(t)]
2-dimensional domain.
DSIP (MU-Sem. 7-COMP) 6-2 Sampling and Quantization
ge
than or equal to 2 Bandwidth (2 w).
1
In other words, t 2w . This is the Whittaker-
io led
Shannon sampling theorem. Only if this condition is
met, can we recover the original signal. These 1-D
Fig. 6.2.1
concepts can be easily extended to the 2-D domain. A
ic ow
We see that convolution replicates the signal f(t) at function f(x, y) is called a band limited function if its
every impulse g(t). Fourier transform F(u, v) is zero outside a bounded
n
Another important property that one needs to know is region in the frequency plane i.e.
bl kn
ge
io led
ic ow
Fig. 6.2.2
Fig. 6.2.3 (a) and (b) represent the Fourier Transform of a band limited signal and its region of support (the base)
n
respectively.
bl kn
at
Pu ch
Te
Fig. 6.2.3(a) : Fourier transform Fig. 6.2.3(b) : Its region of Fig. 6.2.4 : Two dimensional
of a band limited signal support (the base) comb function
Just as in the case of a 1-D function, consider a 2-D To avoid aliasing, the sampling frequency should be
comb function (sampling function) [Refer Fig. 6.2.4] twice the maximum frequency in the signal (image)
A 2-dimensional comb function is defined as 1
x
+ 2u0
…(6.2.1) Where, 2u0 and 2v0 are the bandwidths in the u and v
directions respectively. This is known as the Nyquist
The top view of the comb function is given in Fig. 6.2.4.
condition.
Another way of representing a 2-D function or a
1 1
sampling function is shown in Fig. 6.2.5(a). x = 2u and y = 2v are the lower bounds of the
0 0
The Fourier transform of the comb function with
equation and are known as the Nyquist rate.
spacing of x and y is another COMB function with
spacing 1/x and 1/y. As seen from the Fig. 6.2.6, there is absolutely no
ge
aliasing. If the Nyquist condition is not met,
Comb (u, v) = FT {comb(x, y; x, y)}
overlapping of frequencies occurs and this is known as
= COMB (u, v; 1/x, 1/y) aliasing. This overlapping is shown in Fig. 6.2.7.
io led
The subsampled image is defined as
fs(x, y) = f(x, y) comb (x, y; x, y)
+
ic ow
…(6.2.2)
Since multiplication in the time domain is equal to
at
ge
io led
(c) Hexagonal
Fig. 6.2.9 : Commonly used sampling grids
ic ow
6.3 Quantization
MU - May 2012, May 2013, Dec. 2013.
n
bl kn
Whenever we see an image on the screen of the Fig. 6.3.1 : The first row of the image is plotted.
computer it is actually a matrix which consists of Similarly, if we have 8 bits to represent the grey levels,
8
N M pixels and each pixel is considered to be a we will have 256 grey levels (2 ). Hence more the bits,
ge
sample. Hence more the pixels, more the samples, more are the grey levels and better is the tonal clarity
higher the sampling rate and hence better the spatial (quantization). The total size of the image is
resolution. The value of each pixel is known as the grey N M m, where m is the number of bits used.
io led
level. The x-axis is the number of samples (pixels) in the row
The computer understands only ones and zeros. Hence (sampling) while the y-axis is the grey level of each
these grey levels need to be represented in terms of sample (quantization)
ic ow
zeros and ones. If we have two bits to represent the Now, comes the obvious question. As we know, more
2
n
grey levels, only 4 different grey levels (2 ) can be the samples and the bits, better is the image. What
bl kn
identified viz. 00, 01 10, 11, where 00 is black, 11 is then should be the ideal values of sampling and
white and the other two are different shades of grey. quantization.
at
Pu ch
We shall see the effects of reducing quantization levels and reducing spatial resolution separately.
DSIP (MU-Sem. 7-COMP) 6-7 Sampling and Quantization
ge
figure(2)
imshow(uint8(F1)) io led
[row,col]=size(a);
i=1; j=1;
for x=1:2:row
ic ow
for y=1:2:col
n
c(i,j)=a(x,y);
bl kn
j=j+1;
end
at
Pu ch
end
figure(1),imshow(a)
figure(2),imshow(c)
figure(3),
imagesc(a),colormap(gray)
figure(4)
imagesc(c),colormap(gray)
ge
as number of samples reduce. To compare and understand
the actual effects, we plot them together. To make sure
io led
that they appear to be of the same size, we upsample the
second image. Comparing Fig. 6.3.3(a) and Fig. 6.3.3(c) we
see that the second image has a “Checker board” pattern
ic ow
ge
subjective quality of the image. Another term that we need to understand is the
We have all seen non-uniform sampling been used. Aspect ratio.
Whenever a person’s identity needs to be concealed The ratio of the image’s width to its height, measured
io led
on T.V., non-uniform sampling is used. in unit length or number of pixels is referred to as its
Very few samples are taken near the eye regions aspect ratio. Both, a 3 3 inch image and a 128 128
because of which we see blocks near the person’s eye image have the same aspect ratio of 1.
ic ow
and hence can not make out who that person is. X
Aspect ratio =
Y
n
6.6 Physical Resolution
bl kn
By now we know that a digital image, or image for 6.6.1 Solved Examples on Physical
short, is composed of discrete pixels. These pixels are Resolution
at
Pu ch
Clearly, the total number of pixels in an image is a when printed by a printer at 240 pixels per inch.
function of size of the image and the number of pixels Soln. : Since we have 240 pixels per inch, the physical size
per unit area (example: inch) in the horizontal as well 640 480
as the vertical direction. of the image is 240 by 240.
The number of pixels per unit length is referred to as
the resolution of the displaying device (most of the Ex. 6.6.2 : If we want to resize a 1024 768 image to one
deskjet printers have 670 dpi i.e., 670 dots per inch.). that is 600 pixels wide with the same aspect ratio as the
Thus a 3 2 inch image at a resolution of 300 pixels original image, what should be the height of the resized
per inch would have a total of 540,000 pixels!! image?
In most books as well as in this book, image size is Soln. : We know
given as the total number of pixels in the horizontal
Width
direction times the total number of pixels in the Aspect ratio =
Height
vertical direction (example : 128 128, 512 512,
640 480 ....). For the original image the
Although this convention makes it relatively straight Aspect ratio is = 1024/768 = 1.33
forward to gauge the total number of pixels in an Now for the resized image, we want the same aspect
image, it does not specify the physical size of the ratio but a width of 600 pixels.
image or its resolution as defined in the paragraph
Width 600
above. Height = = = 451
Aspect ratio 1.33
A 640 480 image would measure 6.66 inches by
Hence the resized image will be 600 451.
5 inches when displayed or printed at 96 pixels per
inch. On the other hand, it would measure only
DSIP (MU-Sem. 7-COMP) 6-10 Sampling and Quantization
Ex. 6.6.3 : How much storage capacity is required to store Ex. 6.6.5 : We have a C. T. image which we want to transmit
an image with size of 1024 768 and 256 gray levels ? through a voice grade telephone line. The CT image is of
Soln. : size 512 512 and has 256 grey levels. During transmission
Storage capacity required = A B C each byte is preceded by a start bit and succeeded by a stop
Here A B = Physical size of image = 1024 768 bit. How many minutes will it take to transmit the image ?
C = Number of bits required to get 256 gray (Voice grade telephone lines can transmit 9600-bits/sec)
8
levels, we must have 8 bits (2 = 256) Soln. : 256 grey level required mean 8-bits.
Storage capacity required = 1024 768 8 = 6291456 one packet = [8 + 02] bits = 10 bits
bits image size = 512 512 10
Ex. 6.6.4 : A common measure of transmission for digital image size = 2621440
data is the baud rate, defined as the number of bits 512 512 10
time taken =
transmitted per second. Transmission is accomplished in 9600
packets consisting of a start bit, a byte (8-bits) of information time taken = 273.06 sec 4.5 min
ge
and a stop bit.
(a) How many minutes would it take to transmit a Summary
io led
1024 1024 image with 256 grey levels if we use a
56 k baud modem ? This chapter deals with converting a scene that is
continuous in time and space into an image that can be
(b) What would be the time required if we use a 750 k
ic ow
total number of bits for transmission are has been introduced and the importance of the Nyquist
criteria has been explained. The concept of an image being
N = 1024 1024 10
stored as a matrix has been introduced here. Spatial
N = 10485760-bits resolution and grey level resolution are also explained using
These bits are transmitted at 56 k baud. MATLAB codes.
N
time taken = 3 Review Questions
56 10
time taken = 187.25 sec 3.1 minutes
Q. 1 Explain the concept of aliasing for 1-dimensional
(b) Now if we use a faster transmission line of 750 k baud
signals.
rate, then
Q. 2 Explain the concept of aliasing for 2-dimensional
Time taken to transmit the image
signals.
N 10485760
= Q. 3 How does one avoid aliasing ?
750 10
3 3
750 10
Q. 4 Explain sampling and quantization.
= 13.98 sec 14 sec
Q. 5 Explain the effects of reducing sampling and
quantization.
Q. 6 Explain isopreference curves.
Q. 7 Explain non-uniform sampling.
Image Enhancement in
7 Spatial Domain
Syllabus :
Gray Level Transformations, Zero Memory Point Operations, Neighborhood Processing, Spatial Filtering,
Smoothing and Sharpening Filters, Median Filter.
ge
7.1 Introduction
Image enhancement is one of the first steps in image The term spatial domain means working in the given
io led
processing. As the name suggests, in this technique, space, in this case, the image. It implies working with
the original image is processed so that the resultant the pixel values or in other words, working directly
image is more suitable than the original for specific with the raw data.
ic ow
result varies from person to person. represents black, 255 represents white and all the
An image enhancement technique used to process intermediate values represent shades of grey.
at
Pu ch
images might be excellent for a person, but the same In a image of size 256 256 as shown in the Fig. 7.2.1.
result might not be good enough for another. It is also
Te
The modified image can be expressed as, Since this operation does not require past pixel
g (x, y) = T [f(x, y)] …(7.2.1) values, we do not need additional memory allocation.
Hence point processing is also known as zero memory
Here f(x, y) is the original image and T is the
operation. Some of the common examples of point
transformation applied to it to get a new modified
processing are :
image g(x, y). For all spatial domain techniques it is
simply T that changes. The general equation remains (1) Digital negative
the same. (2) Contrast stretching
To summarize, spatial domain techniques are those, (3) Thresholding
which directly work with the pixel values to get a new (4) Grey level slicing
image based on Equation (7.2.1).
(5) Bit plane slicing
Spatial domain enhancement can be carried out in two
(6) Dynamic range compression
different ways :
(7) Power law transformation
(1) Point processing
ge
(2) Neighbourhood processing
Before we proceed to explain the following examples,
it is important to understand the identity
io led
transformation. The identity transformation is given in
the Fig. 7.3.1.
ic ow
ge
io led
Fig. 7.3.2
Hence when
r = 0, s = 255 and when r = 255, s = 0.
at
Pu ch
end
end
subplot(2,1,1)
imshow(uint8(a))
title(‘Original Image’);
subplot(2,1,2)
imshow(uint8(b))
title(‘Image after Contrast Stretching’)
ge
The formulation of the contrast-stretching algorithm is
given as follows :
lr 0r<a
io led
s = m (r – a) + v ar<b …(7.3.2)
n (r – b) + w br<L–1
where l, m and n are the slopes. It is clear from the
ic ow
Fig. 7.3.4 that l and n are less than one while m is greater (a) Original image (b) Contrast stretched image
than one. The contrast stretching transformation increases
n
Fig. 7.3.5
the dynamic range of the modified image.
bl kn
(3) Thresholding
MATLAB program for contrast stretching
at
p=imread(‘spine.tif’);
a=p;
ge
[row col]=size(a);
T=input(‘Enter value of Threshold :’)
io led
for i=1:1:row
for j=1:1:col
if(p(i,j)<T)
ic ow
a(i,j)=0;
else
n
a(i,j)=255;
bl kn
end
end (b) Slicing with background
at
Pu ch
s = L – 1; if a r b
…(7.3.4)
s=0; otherwise
This method is known as Grey level slicing without
background. This is because in this process, we have
completely lost the background. In some applications,
we not only need to enhance a band of grey levels but
also need to retain the background.
(a) Original image of spine (b) Image obtained
This technique of retaining the background is called as
using threshold
Grey-level slicing with background. The transformation
Fig. 7.3.7
is as shown in the Fig. 7.3.8(b).
(4) Grey level slicing (Intensity slicing) The formulation for this is
What thresholding does is it splits the grey level into s = L – 1; if a r b
…(7.3.5)
two parts. At times, we need to highlight a specific s=r; otherwise
range of grey values like for example enhancing the MATLAB program for grey level slicing with and
flaws in an X-ray or a CT image. without background is as follows :
In such circumstances, we use a transformation known %% Grey level slicing without background %%
as grey level slicing. The transformation is shown in clear all
the Fig. 7.3.8(a). It looks similar to the thresholding clc
function except that here we select a band of grey p=imread (‘skull.tif’);
level values. z=double (p);
DSIP (MU-Sem. 7-COMP) 7-6 Image Enhancement in Spatial Domain
[row,col]=size(z)
for i=1:1:row
for j=1:1:col
if((z(i,j)>50))&&(z(i,j)<150)
z(i,j)=255;
else
z(i,j)=0; (a) Original image (b) Grey level slicing
ge
imshow (uint8(z)) 256 256 8 image. In this, 256 256 is the number
io led of pixels present in the image and 8 is the number of
bits required to represent each pixel. 8-bits simply
means 28 or 256 grey levels.
Now each pixel will be represented by 8-bits. For
ic ow
without background the importance of each bit in the final image. This can
Fig. 7.3.9 be done as follows.
at
Pu ch
MATLAB program Consider the LSB value of each pixel and plot the
%% Grey level slicing with backgound %% image using only the LSBs. Continue doing this for each
bit till we come to the MSB. Note that we will get
Te
clear all
8 different images and all the 8 images will be binary.
clc
p=imread(‘skull.tif’); Solved Example
z=double(p);
Ex. 7.3.1 : Given a 3 3 image, plot its bit planes.
[row col]=size(p);
for i=1:1:row 1 2 0
for j=1:1:col 4 3 2
if(z(i,j)>50))&&(z(i,j)<150)
7 5 2
z(i,j)=255;
Soln. : Since 7 is the maximum grey level, we need only
else
3-bits to represent the grey levels.
z(i,j)=p(i,j);
end Hence we will have 3-bit planes. Converting the image
to binary we get,
end
end 001 010 000 1 0 0 0 1 0 0 0 0
figure (1); %------- original image.
imshow(p) 100 011 010 0 1 0 0 1 1 1 0 0
figure (2); %------- grey level slicing with background 111 101 010 1 1 0 1 0 1 1 1 0
imshow (uint8(z))
Binary image LSB plane Middle bit MSB
plane plane
DSIP (MU-Sem. 7-COMP) 7-7 Image Enhancement in Spatial Domain
ge
d=c(r); that during daytime, we cannot see the stars. The
w(x,y)=double(d); %% since w is a char and reason behind this is that the intensity of the sun is so
cannot be plotted
io led large and that of the stars is so low that the eye cannot
if w(x,y)==49 %% since double of d will be either 49 adjust to such a large dynamic range.
or 48
In image processing, a classic example of such large
w(x,y)=255;
ic ow
end
In the Fourier spectrum only some of the values are
end
very large while most of the values are too small. The
at
end
Pu ch
6
dynamic range of pixels is of the order of 10 . Hence,
figure(1) when we plot the Fourier spectrum, we see only small
imshow(uint8(a)) dots, which represent the large values.
Te
MATLAB program for dynamic range compression The power law transformation can also be used to
%% Dynamic range compression %% improve the dynamic range of an image. Given below
clear all is the MATLAB code for power transformation. The
clc final image has been normalized to 0 - 255 range.
aa=imread(‘saturn.tif’);
a=double(aa) ;
[row,col]=size(a);
for x=1:1:row
for y=1:1:col
c(x,y)=a(x,y)*((-1)^(x+y)); %% Needed to center the
transform
end
end
ge
d=abs(fft2(c));
Fig. 7.3.13 : Gamma correction factor
d_log=log(1+d);
%%% Plotting %% Power transformation %%
io led
figure(1) clear all
colormap(gray) clc
imagesc(d)
ic ow
img1=imread(‘test.tif’);
figure(2) [row,col]=size(img1);
n
colormap(gray)
gamma=input(‘Enter the correction factor: ’);
bl kn
imagesc(d_log)
img=double(img1);
at
Pu ch
for i=1:row
for j=1:col
Te
nuimg(i,j)=img(i,j)^gamma
end
(a) (b) end
Fig. 7.3.12 : Dynamic range compression numax=max(max(nuimg));
ge
a time and modify it depending on our requirement,
here we not only consider a pixel but also its + f(x, y) w5 + ….……+ f(x + 1, y + 1) w9
immediate neighbours. ...(7.4.1)
io led
To cut a long story short, we change the value of the
pixel f(x, y) based on the values of its 8 neighbours as
shown in Fig. 7.4.1. Instead of a 3 3 neighbourhood,
ic ow
Fig. 7.4.3
We can conclude that the lower signal is of a much (1) Gaussian noise : The Probability Density Function
higher frequency, by checking the number of (PDF) of Gaussian noise is given by the formula,
2 2
oscillations. That is, higher the frequency, greater are – (z –) / 2
1e
the number of oscillations. p(z) =
2
If the two signals represent voltages, then, how fast
z Grey level
the voltages change is an indication of the frequency.
Mean of average value of z
The same concepts can be applied to images.
Standard deviation
In images, instead of voltages, we have grey levels. If
the grey levels change slowly over a region, it is Variance
considered to have low frequency, whereas, if the grey
levels change very rapidly, that region is considered to
have high frequencies.
Hence in images, regions where the grey levels change
ge
slowly are low frequency areas and regions which have
abrupt grey level changes, are high frequency areas.
Always remember this.
io led
In most of the images, the background is considered to
be a low frequency region, whereas the edges are Fig. 7.4.5
considered to be high frequency regions. Hence low
ic ow
Low pass filtering as the name suggests removes the Consider the image shown in Fig. 7.4.6.
high frequency content from the image. It is used to
Te
7.4.2 Noise
The principal sources of noise in a digital image arise
during image acquisition and during transmission. No
matter how much care one takes, some amount of noise
always creeps in. Based on the shapes (Probability Density
Functions) of the noise, they are classified as :
(1) Gaussian noise (2) Salt and pepper noise Fig. 7.4.8
(3) Rayleigh noise (4) Gamma noise There are two constant regions in the image. Hence,
the histogram of the image is as shown in Fig. 7.4.7. If in
(5) Exponential noise (6) Uniform noise
this image, Gaussian noise creeps in, the histogram gets
Of these, the first two are more common than the
modified as shown in Fig. 7.4.8. Gaussian noise arise in an
others. We shall explain the Gaussian and salt and pepper
image due to factors such as circuit noise, sensor noise
noise in this chapter.
poor illumination and high temperature.
DSIP (MU-Sem. 7-COMP) 7-11 Image Enhancement in Spatial Domain
ge
Fig. 7.4.9
Generally a and b are black and white grey levels
io led
respectively. Hence for a 8-bit image, a = 0, b = 255
because of which the noise is called salt (white) and pepper
(black). Some books refer to it as speckle noise.
ic ow
Fig. 7.4.11
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
ge
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10
io led 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
ic ow
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
n
bl kn
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
at
Pu ch
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
We place a 3 3 mask on this image. We start from
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
the left hand top corner. We cannot work with the
Te
Note : The resultant should be written in a new matrix The last one in the sequence being
(image). 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
50 50 50 50 50 50 50 50
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
DSIP (MU-Sem. 7-COMP) 7-13 Image Enhancement in Spatial Domain
ge
remained unchanged, but the sharp edge between 10
and 50 has become blurred.
io led
The transition has reduced. Now from 10, the grey
level changes to 23.3 (23 after rounding off), from 23 it
changes to 36.6 (36 after rounding off) and finally from
ic ow
averaging masks are shown. %% Low pass filtering of an image using averaging
technique
0 1 0 1 1 1
clear all;
1 1
6 1 2 1 10 1 2 1 clc;
0 1 0 1 1 1 a=imread(‘blood.tif’);
a=double(a);
MATLAB program for low pass filtering along with the [row col]=size(a)
images with Gaussian noise
m=input(‘Enter the mask size:’);
%% Low pass filter used on an image with Gaussian noise n=m^2;
clear all for i=1:1:m
clc for j=1:1:m
aa=imread(‘xray.tif’); % size 600 800 w(i,j)=1/n;
f=double(aa); end
ab=imnoise(aa,’gaussian’); % adding noise end
a=double(ab); s=(m+1)/2;
w=[1 1 1; 1 1 1; 1 1 1]/9 for x=1:1:row
[row col]=size(a); for y=1:1:col
for x=2:1:row-1 b(x,y)=a(x,y);
for y=2:1:col-1 end
end
DSIP (MU-Sem. 7-COMP) 7-14 Image Enhancement in Spatial Domain
ge
end shall explain median filtering with an example.
subplot (3,1,1) In the image shown below let 250 be the salt and
imshow (uint8(a)) pepper noise. If we use an averaging filter, the noise
io led
title (‘Original Image’); would spread out and the edges would also end up
subplot (3,1,2) getting blurred. If we only want to remove the noise
without disturbing the edges, we use a median filter.
imshow (uint8(b))
ic ow
10 10 10 10 10 10 10 10
subplot(3,1,3)
imshow(uint8(c)) 10 250 10 10 10 10 10 10
at
Pu ch
MU - Dec. 2017 50 50 50 50 50 50 50 50
Q. Write short notes on : Median Filter.
50 50 50 50 50 50 50 50
(Dec. 2017, 5 Marks)
50 50 50 50 50 50 50 50
The averaging filter removes the noise by blurring it till
it is no longer seen. But in the process, it also blurs the Just like the earlier case, we start by placing the mask
edges. Bigger the averaging mask more is the blurring. at the left hand corner. We again ignore the borders.
There are times when the image contains salt and
10 10 10 10 10 10 10 10
pepper noise.
If we use an averaging filter to remove the same, it will 10 10 10 10 10 10 10 10
blur the noise but it would also ruin the edges. Hence 10 250 10 10 10 10 10 10
when we need to eliminate salt and pepper noise, we
work with a non-linear filter known as the Median 10 10 10 10 10 10 10 10
filter. 50 50 50 50 50 250 50 50
They are also called order-statistic filters because their
response is based on the ordering or ranking of the 50 50 50 50 50 50 50 50
pixels contained within the mask. 50 50 50 50 50 50 50 50
In this case, we use a mask similar to the averaging
50 50 50 50 50 50 50 50
filter except that the mask has no values. So it’s like
working directly with the 8 neighbours of the centre
pixel.
DSIP (MU-Sem. 7-COMP) 7-15 Image Enhancement in Spatial Domain
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 250 10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
50 50 50 50 50 250 50 50 50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
ge
Arranging the 9 pixels in ascending or descending Solved Example
order we get,
Ex. 7.4.1 : If x = {2 3 4 3 4 5 6} and w = {–1 0 1}, perform
io led
(10, 10, 10, 10, 10, 10, 10, 10, 250)
th median filtering.
The median is the 5 value since the mask is 3 3
mask. This value is placed at the center. We now move Soln. : w = {–1, 0, 1} simply means that the size of the mask
ic ow
the mask to the new location and continue the is 1 3 and the term 0 indicates the position from where
procedure. Performing this operation on the entire
n
the filtering starts.
image, we get the final image.
bl kn
Fig. P. 7.4.1
DSIP (MU-Sem. 7-COMP) 7-16 Image Enhancement in Spatial Domain
ge
a2=sort(a1); The frequency response and the spatial response of a
med=a2(5); % the fifth value is the median high pass filter are shown in Fig. 7.5.1.
b(x,y)=med
io led As seen from the spatial response, it is clear that the
end mask coefficients have to be such that they have a
end positive value at the centre and negative values at the
figure(1)
ic ow
periphery.
Imshow(uint8(J))
One of the high pass masks is shown in Fig. 7.5.1.
figure(2)
n
imshow(uint8(b)) The important thing to note is that the sum of the
bl kn
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
100 100 100 100 100 100 100 100
(a) Original image with (b) Median filtered image
100 100 100 100 100 100 100 100
salt and pepper noise
100 100 100 100 100 100 100 100
Fig. P. 7.4.1 100 100 100 100 100 100 100 100
Fig. 7.5.1
DSIP (MU-Sem. 7-COMP) 7-17 Image Enhancement in Spatial Domain
By now we know what to expect when we do a high Note that 1/9 is simply a scaling function unlike the
pass operation. The background, which is low low pass mask in which the 1/9 term is a part of the
frequency, gets eliminated while the edges get averaging operation. In this case we could also work with
enhanced. 1/8 or 1/7 depending on the image. Some of the other high
We move the mask in a similar fashion as in the low pass masks are as follows
pass filter example. The output that we get is shown
below. Note that the background has been eliminated 0 –1 0 –1 –2 –1
and we get all zero values. This is because the sum of
the mask coefficients is zero. –1 4 –1 –2 12 –2
0 0 0 0 0 0 0 0
0 –1 0 –1 –2 –1
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 The result using the first mask and putting negative
values as zeros is.
–270 –270 –270 –270 –270 –270 –270 –270
270 270 270 270 270 270 270 270 0 0 0 0 0 0 0 0
ge
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
io led
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
There are two issues to be dealt with, when working 30 30 30 30 30 30 30 30
ic ow
for that is –270 is a value that is lower than zero, that %% High pass filtering %%
is, it is supposed to be darker than the darkest value clear all
Te
–1 –1 –1
1
9 –1 8.9 –1
–1 –1 –1
ge
does not eliminate the background completely. This
There are times, when we need to enhance the edges technique is one of the basic tools that is used in the
but also retain some of the background. To do that, we printing industry.
io led
use a modified version of the high pass filter known as There are other neighbourhood techniques like
High-Boost filtering. Robert’s filtering, Sobel’s filtering and Prewitt’s
In High-Boost filtering, we pass some of the filtering, which are similar to the methods discussed
ic ow
background along with the high frequency content. above. They form a separate chapter called
We know that, High pass = Original – Low pass Segmentation and hence would be discussed later.
n
bl kn
To pass some of the background, we multiply the MATLAB program for high-boost filtering
original image with a multiplicative factor A. This gives %% High boost filtering
at
Hence, clc
High Boost = (A) original – Low pass aa=imread (‘xray.tif’);
Te
If A > 1, then some of the original signal is added back for x=2:1:row-1
to the high pass result. This process restores some of for y=:1:col-1
the background into the high passed image. This a1(x,y)= w(1)*a(x-1,y-1)+w(2)*
technique is also known as unsharp masking. The a(x-1,y)+w(3)* …
mask coefficients for high boost filtering are as a(x-1,y+1)+w(4)*a(x,y-
follows, 1)+w(5)*a(x,y)+w(6)* …
Here X= 9A – 1 a(x,y+1)+w(7)*a(x+1,y-
1)+w(8)*a(x+1,y)+w(9)* …
Hence if A= 1, X = 8 which is a high pass mask.
a(x+1,y+1);
–1 –1 –1
1 end
9 –1 X –1 end
–1 –1 –1 figure(1)
imshow(uint8(a))
3 3 High boost mask
figure(2)
If A = 1.1, X = 8.9.
imshow(uint8(a1))
DSIP (MU-Sem. 7-COMP) 7-19 Image Enhancement in Spatial Domain
end
end
n=0
for x=s:1:row-s
for y=s:1:col-s
if b(x,y) > n
n=b(x,y);
(a) Original (b) High boost end
Fig. 7.6.1 end
The generalized MATLAB program for high pass end
filtering using any mask size is given next. c=255/n;
%% High pass filtering of an image %% for x=s:1:row-s
clear all; for y=s:1:col-s
ge
clc; b(x,y)=c*b(x,y);
a=imread(‘mri2.tif’); end
a=double(a); end
io led
[row col]=size(a); subplot(2,1,1)
m = input(‘Enter the mask size:’); imshow(uint8(a))
title(‘Original Image’);
ic ow
for i=1:1:m
for j=1:1:m subplot(2,1,2)
n
w(i,j)=-1 imshow(uint8(b))
bl kn
7.7 Zooming
Pu ch
s=(m+1)/2;
w(s,s)=m^2-1;
Another important application in image enhancement
for x=1:1:row
Te
7.7.1 Replication 1 0 2 0 3 0 4 0
This is also known as zero interlacing the columns, as
In replication, we simply replicate each pixel and then
we add zeros at every other column. Now inserting a
replicate each row. Consider the pseudo-image shown
row full of zeros gives us. This is known as zero
below. interlacing the rows as we add zeros at every other
1 2 3 4 row.
5 6 7 8 1 0 2 0 3 0 4 0
0 0 0 0 0 0 0 0
9 8 6 7
1 0 2 0 3 0 4 0
0 1 2 3
0 0 0 0 0 0 0 0
As stated earlier, we start from the first row. We
replicate each pixel and then replicate each row. The 5 0 6 0 7 0 8 0
first row now looks like 0 0 0 0 0 0 0 0
ge
1 1 2 2 3 3 4 4
9 0 8 0 6 0 7 0
We now replicate this row to get
io led 0 0 0 0 0 0 0 0
1 1 2 2 3 3 4 4
1 1 2 2 3 3 4 4 0 0 1 0 2 0 3 0
ic ow
1 1 2 2 3 3 4 4
get the zoomed image.
5 5 6 6 7 7 8 8
at
1 1
Pu ch
5 5 6 6 7 7 8 8
1 1
9 9 8 8 6 6 7 7
Te
0 0 1 1 2 2 3 3 1 1 2 2 3 3 4 4
As mentioned earlier, zooming by replication gives the This is the first step. We now proceed to find the
final image a patchy look since clusters of grey levels average values along the columns. Hence the final
are formed. This can be substantially reduced by using image is as shown. In practice, we need to round of
a better method of zooming known as interpolation. the pixel values.
ge
operation is done on the interlaced image. 9 8.5 8 7 6 6.5 7 3.5
1 0 2 0 3
io led 0 4 0 4.5 4.5 4.5 4.25 4 4.5 5 2.5
0 0 0 0 0 0 0 0
0 0.5 1 1.5 2 2.5 3 1.5
5 0 6 0 7 0 8 0
0 0 0 0 0 0 0 0 0 0.25 0.5 0.75 1 1.25 1.5 0.75
ic ow
0 0 1 0 2 0 3 0
interpolated image. Hence we can conclude that
0 0 0 0 0 0 0
zooming by interpolation is more effective than
at
Pu ch
ge
figure(3),imshow(uint8 (A2))
3 1 2 4
5 1 6 2
io led
2 3 5 6
Fig. 7.7.2 s = (L – 1) – r
or g (x, y) = (L – 1) – f (x, y)
7.8 Solved Examples
at
Pu ch
3
Here L = 2 = 8
Ex. 7.8.1 : Obtain the digital negative of the following 8 Bits
s = 7–r
Te
1 0 0 0 0 1 1 0 0 1 0 1
0 0 0 1 1 0 1 0 1 1 0 0
1 0 1 0 0 0 1 1 1 1 0 0
0 0 1 1 1 1 0 1 0 1 1 0
ge
4 3 2 1 Hence we have the required slopes to compute
contrast stretching. The contrast stretching formula is given
io led
3 1 2 4 below.
f (x, y) =
5 1 6 2
r 0r<3
s = (r – r1) + s1 3 r < 5
ic ow
2 3 5 6 (r – r ) + s 5 r < 7
2 2
n
MU - May 2016, 10 Marks. Here r1 = 3, r2 = 5, s1 = 2, s2 = 6
bl kn
Contrast stretching r2 = 5, r1 = 3, s2 = 6, s1 = 2 :
contrast stretching formula.
4 3 2 1
r s
Te
f (x, y) = 3 1 2 4
0 s = r = 0.66 0 = 0
5 1 6 2
1 s = r = 0.66 1 = 0.66
2 3 5 6
2 s = r = 0.66 2 = 1.32
The contrast stretching transformation is shown in 3 s = (r – r1) + s1 = 2 (3 – 3) + 2 = 2
Fig. P. 7.8.3.
4 s = (r – r1) + s1 = 2 (4 – 3) + 2 = 4
From the values of r1 and s1 we can find the slope of .
In a similar manner, we can find the value of using the 5 s = (r – r2) + s2 = 0.5 (5 – 5) + 6 = 6
values of r1, r2 and s1, s2. 6 s = (r – r2) + s2 = 0.5 (6 – 5) + 6 = 6.5
From the values of r2 and s2, we can find the value of .
7 s = (r – r2) + s2 = 0.5 (7 – 5) + 6 = 7
s1 2
= = = 0.66 Hence the contrast stretched image is
r1 3
y2 – y1 6 – 2 4 2 1.32 0.66
= = =2
x2 – x1 5 – 3
2 0.66 1.32 4
y2 – y1 7 – 6
Finally, = = = 0.5 6 0.66 6.5 1.32
x2 – x1 7 – 5
1.32 2 6 6.5
DSIP (MU-Sem. 7-COMP) 7-24 Image Enhancement in Spatial Domain
4 2 1 1
0 if f(x, y) 4
If we round off, the final 2 1 1 4
image would be 6 1 7 1 g(x, y) =
1 2 6 7 L–1 if f(x, y) 4
Ex. 7.8.4 : For the 3-bit 4 4 size image, perform the Here
following operations : L–1 = 7
(i) Negation The thresholded image is as follows,
(ii) Thresholding with T = 4
7 7 7 7
(iii) Intensity level slicing with background r1 = 2 and r2 = 5
(iv) Bit plane slicing for MSB and LSB planes
7 0 0 0
(v) Clipping with r1 = 2 and r2 = 5 0 7 0 7
ge
1 2 3 0 7 7 0 7
2 4 6 7
(iii) Bit plane slicing
5 2
io led 4 3
We convert the given image into binary and then
3 2 6 1 separate the plane. Since the given image is 3-bit, the
Soln. : Let the given image be f(x, y) binary image would be as follows,
ic ow
g (x, y) = (L – 1) – f(x, y)
Pu ch
3
011 010 110 001
Since the image is 3-bit, L = 2 = 8
Separating the bit planes we obtain.
L–1 = 7
Te
g(x, y) = 7 – f(x, y) 0 0 0 0 0 1 1 0 1 0 1 0
6 5 4 7 1 0 1 0 0 1 0 1 1 0 0 1
g(x, y) = 5 3 1 0 0 0 1 0 1 1 1 1 1 0 0 1
r 2 r 5 s=L–1 r1 r r2 s=L–1 r1 r r2
s =
0 otherwise s=0 otherwise s= r otherwise
Hence the final clipped image is as follows,
0 0 0 0 0 2 1 2 2 1
0 2 3 0
2 4 0 0 0 7 7 7 0 2 7 7 7 2
5 2 4 3 0 0 0 0 0 6 2 7 6 0
3 2 0 0
0 0 0 7 0 2 6 6 7 1
Ex. 7.8.5 : Perform intensity level (grey level) slicing on the
3 BPP image. Let r1 = 3 and r2 = 5. Draw the modified image 0 7 0 0 0 0 7 2 2 1
using with background and without background Without background With background
transformations.
Ex. 7.8.6 : The grey levels in an image range from 10 to 50.
ge
Soln. : Let us draw the grey level transformation.
We need to display the image on a device that has a grey
2 1 2 2 1 level range of 0 to 255. Give a transformation which would
io led
2 3 4 5 2 accomplish this.
2 6 6 5 1 Range normalization.
0 3 2 2 1 It is given by,
n
d–c
bl kn
s (x, y) = [r (x, y) – a] + c
b–a
at
When r = 10, s = 0
(a)
r = 50, s = 255
0 1 1 1 1 4
1 1 2 3 2 2
1 1 2 2 3 3
1 2 4 6 2 3
1 2 4 2 4 4
(b)
1 2 3 7 2 5
Fig. P. 7.8.5
DSIP (MU-Sem. 7-COMP) 7-26 Image Enhancement in Spatial Domain
Soln. : When we apply the LPF on the image, the center pixel
ge
0 0 1 –1 –1 –1
1 0 1
2 2 2 9 –1 8 –1
io led
3 2
–1 –1 –1
4 4 3
5 4 Note : We can also prove this by taking a pseudo-image.
ic ow
0 2 4 6 2 2 f (x, y) = 4 2 5 1
0 2 4 2 4 4 1 2 6 3
0 2 2 6 2 4 2 4 6 7
Soln. :
Ex. 7.8.8 : Show that a high pass filtered image can be
A 3 3 averaging mask is shown below :
obtained in the spatial domain as High pass = Original – Low
pass. 1 1 1
Soln. : 1
w (x, y) =9 1 1 1
Original image Low pass filter High pass filter 1 1 1
z7 z8 z9 1/9 1/9 1/9 –1/9 –1/9 –1/9 In this, we zero pad the image before performing the
filtering operation. This gives us a 6 6 image.
DSIP (MU-Sem. 7-COMP) 7-27 Image Enhancement in Spatial Domain
1 1 2 3 2 2
0 0 0 0 0 0
1 2 2.55 2.44 2.33 2
0 1 2 3 2 0 4 2 2.88 2.88 2.88 1
g (x, y) =
1 2.44 3.55 4 4.33 3
0 4 2 5 1 0
f (x, y) = 2 2.22 3.66 5 5.77 7
0 1 2 6 3 0 2 2 4 6 7 7
ge
g (x, y) = f (x, y) w (x, y)
0 0 0 0 0 0
io led
0 1 1.88 1.66 1.22 0
Fig. P. 7.8.10
ic ow
0 0 0 0 0 0
g(x, y) = f1 (m, n) f2 (x –m, y – n)
(ii) Pixel replication
Te
m n
1 1 2 3 2 2
1 1 2 3 2 2
4 4 2 5 1 1
f (x, y) =
1 1 2 6 3 3
Fig. P. 7.8.10(a)
2 2 4 6 7 7 The basic shift operations are
2 2 4 6 7 7
Fig. P. 7.8.10(b)
DSIP (MU-Sem. 7-COMP) 7-28 Image Enhancement in Spatial Domain
f2(m, n) fliping about m-axis f2(m, n) fliping about n-axis
ge
io led
ic ow
n
bl kn
at
Pu ch
Te
Fig. P. 7.8.10(c)cont…
DSIP (MU-Sem. 7-COMP) 7-29 Image Enhancement in Spatial Domain
corel 2
ge
io led
ic ow
n
bl kn
at
Pu ch
Te
Fig. P. 7.8.10(c)
Fig. P. 7.8.11(a)
ge
We see that the results are the same as obtained from the previous
method.
io led
ic ow
Fig. P. 7.8.11(b)
n
Ex. 7.8.12 : Apply Low and High Pass Spatial masks on the following Fig. P. 7.8.12 matrix.
bl kn
Prove that High pass = Original – Low pass. Assume virtual Rows and Columns.
30 31 32
at
Pu ch
f(x,y) = 33 120 30
32 32 31
Te
Fig. P. 7.8.12
0 0 0 0 0
0 30 31 32 0
f(x,y) = 0 33 120 30 0
0 32 32 31 0
0 0 0 0 0
We convolve this image with a standard 3 3 Low pass and a High pass mask.
1 1 1
Low pass mask h1 (x,y) = 1 1 1
1 1 1
DSIP (MU-Sem. 7-COMP) 7-31 Image Enhancement in Spatial Domain
–1 –1 –1
High pass mask h2 (x,y) = 1
–1 8 –1
9
–1 –1 –1
ge
g2 (x,y) = f (x,y) * h2 (x,y) =
io led 2.11 78.77 – 0.667
This is the same as the High pass result. Therefore, High pass = Original – Low pass
Here m1 n1 is the size of f(x, y) [ 2 and m2 n2 is
Ex. 7.8.13 : Given f (x, y) =
5 6 7
, 1 2
h(x, y) = the size of h(x, y) [2 2], Therefore m1 = 2, m2 = 2, n1 = 3,
8 9 10 3 4
n2 = 2. Hence zero padding should be done in such a
Find linear convolution of input image f(x, y) with filter of
manner so that f1 (x, y) and h(x, y) are of size
h(x, y).
(2 + 2 – 1) (3 + 2 – 1).
Soln. : Let the output image be g (x, y)
= 34
Here, g (x, y) = f(x, y) h(x, y)
0 0 0 0
We shall solve this using the circular matrix method.
(The other method is the graphical technique). f (x, y) = 5 6 7 0 ; h(x, y)
We zero pad f(x, y) and h(x, y) in such a way that both 9 10 0
of them are of size. 0 0 0 0
(m1 + m2 – 1) (n1 + n2 – 1)
= 1 2 0 0
4 0 0
DSIP (MU-Sem. 7-COMP) 7-32 Image Enhancement in Spatial Domain
We now arrange one of these as a circular matrix and the other one as a row slacking matrix. Let us convert f(x, y) to a
circular matrix. Let the encircled terms be the starting points
8 0 0 0 0 0 7 6 5 0 10 9 3
9 8 0 0 0 0 0 7 6 5 0 10 4
10 9 8 0 0 0 0 0 7 6 5 0 0
0 10 9 8 0 0 0 0 0 7 6 5 0
5 0 10 9 8 0 0 0 0 0 7 6 × 1
6 5 0 10 9 8 0 0 0 0 0 7 2
7 6 5 0 10 9 8 0 0 0 0 0 0
0 7 6 5 0 10 9 8 0 0 0 0 0
ge
0 0 7 6 5 0 10 9 8 0 0 0 0
0 0 0 7 6 5 0 10 9 8 0 0 0
io led
0 0 0 0 7 6 5 0 10 9 8 0 0
0 0 0 0 0 7 6 5 0 10 9 8 0
ic ow
Multiplying the two matrices gives us Ex. 7.8.14 : For the given 3 bit, 4 4 size image perform
n
bl kn
66 r2 = 5
40 (iii) Bit plane slicing for LSB and MSB planes
Te
23 (iv) Negation.
4 2 3 0
63
1 3 5 7
73
5 3 2 1
48
2 4 6 7
5
MU - Dec. 2011, 10 Marks)
16
Soln. :
19
(i) Thresholding (T = 4)
14 3
Since the given image is 3-bit, L = 2 = 8
We re-arrange this matrix to generate a filtered image. The transformation for thresholding is shown in
5 16 19 14 Fig. P. 7.8.14.
g(x, y) = 23 63 73 48 Here,
24 59 66 40 s = L–1=7 r4
We would get the same answer if we make h(x, y) into s = 0 r<4
a circular matrix instead of f(x, y). Go ahead and try it out
yourself.
DSIP (MU-Sem. 7-COMP) 7-33 Image Enhancement in Spatial Domain
ge
0 0 1 0 1 0 0 0
0 7 7 7
1 1 1 1 0 0 1 1
(ii)
io led
Intensity level slicing with background for
r1 = 2, r2 = 5 1 1 0 1 1 0 0 0
in Fig. P. 7.8.14(a).
LSB plane MSB plane
Here,
n
bl kn
Fig. P. 7.8.14(b).
Here,
Te
s = (L – 1) – r
s = 7–r
Here the grey levels get inverted.
Fig. P. 7.8.14(a)
Fig. P. 7.8.14(b)
7 7 7 0
3 5 4 7
1 7 7 7
6 4 2 0
7 7 7 1
2 4 5 6
7 7 6 7
5 3 1 0
DSIP (MU-Sem. 7-COMP) 7-34 Image Enhancement in Spatial Domain
1. Contrast stretching increases the dynamic range by Thresholding also increase that dynamic range by
making the dark pixels darker and bright pixels setting a threshold. All values less than the threshold
brighter. are made black while values greater than the threshold
are made equal to white.
2. The formula of the contrast-stretching algorithm is The formula for achieving thresholding is as follows :
given below : s=0; if ra
lr 0r<a s=L–1; if r>a
s = m (r – a) + v a r < b
n (r – b) + w b r < L – 1
ge
3. The transformation for contrast stretching is shown The transformation for thresholding is shown below :
below :
io led
ic ow
n
bl kn
at
Pu ch
4. We can adjust the contrast in an image by changing the Thresholding is extreme contrast stretching. In other
Te
5. The final result of contrast stretching gives us a grey The final result of thresholding gives us a binary image.
scale image. The output image has different shades of Which means that the thresholded image has only
grey. black and white values.
In this chapter, we introduce the term spatial domain Q. 1 Explain spatial domain processing.
and image enhancement in the spatial domain. Different
image enhancement techniques that improve the Q. 2 Compare and contrast average filtering and median
subjective quality of the image are explained. The methods filtering.
described here can be classified into two broad groups :
Q. 3 Explain the difference between operations involving
point processing and neighborhood processing. The
3 3 mask for median filtering and average filtering.
concept of frequencies in an image is explained using
simple illustrations. Basic filtering operations such low pass Q. 4 Develop a procedure for computing the median in
filtering and high pass filtering are presented. Advantages n n neighbourhood.
of each of the operations are stated using MATLAB codes.
Any particular technique that may be applied depends on Q. 5 What do we mean by Gaussian noise and why is an
the subjective quality of the image as well as the purpose averaging filter used to eliminate it ?
behind the processing. It must be noted that more than one
technique can be used to get the desired result.
DSIP (MU-Sem. 7-COMP) 7-35 Image Enhancement in Spatial Domain
Q. 6 What is salt and pepper noise (binary noise) and how Q. 14 Given a image, what is the output using a 3 H 3
does a median filter remove it ? averaging filter and a medain filter ? Explain the
result.
Q. 7 Explain the output and application of the following
3 3 3 33 3
zero memory enhancement techniques.
3 3 3 33 3
(1) Contrast stretching
3 3 10 10 3 3
(2) Thresholding
3 10 3 33 3
(3) Range compression
3 3 3 38 3
(4) Bit extraction.
3 3 3 33 3
Q.8 Compare and contrast the low pass and high pass 3 3 3 33 3
spatial filters. 3 3 3 33 3
Q. 9 Explain why a median filter is called a salt and pepper Q. 15 How is image subtraction carried out ? Give an
ge
filter. example of image subtraction in the field of medicine.
Q. 10 Compare and contrast the smoothing and sharpening Q. 16 Explain the procedure of zooming an image using
io led
filters. replication and interpolation.
Q. 11 Low pass filter is a smoothing filter. Explain. Q. 17 Why should the sum of any high pass mask be zero ?
ic ow
2 1
Pu ch
5 6 3
Te
Fig. Q. 18
8 Histogram Modelling
Syllabus
Histogram Processing, Histogram equalization
Histogram of images provide a global description of In the second method, instead of plotting the number
the appearance of an image. The information obtained of pixels directly, we plot their probability of occurrence
ge
from histograms is enormous and hence histogram i.e.,
modelling; though a spatial domain technique is nk
p(rk) =
introduced as a separate chapter. n
io led th
By definition, histogram of an image represents the Where, rk k grey level
relative frequency of occurrence of the various grey th
nk Number of pixels in the k grey level
levels in an image. Histogram of an image can be
ic ow
the y-axis has the number of pixels in each grey level, (nk) p(rk) = n
while in the second method, the x-axis represents the
0 40 0.4
at
1 20 0.2
of the occurrence of that grey level.
2 10 0.1
Method 1 3 15 0.15
Te
4 10 0.1
Grey level Number of pixels (nk)
5 3 0.03
0 40 6 2 0.02
1 20
n = 100
2 10
3 15
4 10
5 3
6 2
Fig. 8.1.2
Just by looking at the histogram of the image, a great Our aim in this chapter would be to transform the first
deal of information can be obtained. Some of the three histograms into the fourth histogram. In other
typical histograms are shown in Fig. 8.1.3. words, we try to increase the dynamic range of the
image. Though MATLAB has a inbuilt function to plot
the histogram (hist) we shall write our own code.
MATLAB code for plotting the histogram of an image.
%% Program for histogram %%
clear all
clc
a=imread(‘test.tif’);
a=double(a);
(a) [row col]=size(a);
h=zeros(1,300);
for n=1:1:row
ge
for m=1:1:col
if a(n,m)==0
%% To ensure that the values of a are not zero
io led
a(n,m)=1;
end
end
ic ow
(b) end
for n=1:1:row
n
for m=1:1:col
bl kn
t=a(n,m);
%% Takes the value of the pixel ex. 12
h(t)=h(t)+1;
at
Pu ch
end
(c) %% PLOTTING %%
figure (1)
imshow(uint8(a))
figure(2)
bar(h)
(d)
Fig. 8.1.3
Fig. 8.2.1
ge
dynamic range. We do this by using a straight line
Fig. 8.1.4(b) : Histogram of image
equation having slope (smax – smin) / (rmax – rmin).
io led
8.1.1 Mean and Standard Deviation of Where, smax Maximum grey level of output image
Histogram smin Minimum grey level of output image
rmax Maximum grey level of input image
ic ow
+ (4 5))/32 = 2.46
8.2.1 Solved Examples on Linear Stretching
2. Standard deviation (σ) : In image processing, standard
deviation is a measure that is used to measure the Ex. 8.2.1 : Perform histogram stretching so that the new
amount of variation of grey levels from the mean. A image has a dynamic range of [0, 7].
standard deviation close to 0 indicates that the data
Grey 0 1 2 3 4 5 6 7
points tend to be very close to the mean of the image,
level
while a high standard deviation indicates that the data
points are spread out over a wider range of grey level Number 0 0 50 60 50 20 10 0
values. of pixels
DSIP (MU-Sem. 7-COMP) 8-4 Histogram Modelling
ge
r=4 s=4 Fig. P. 8.2.2
smax – smin
Grey level 0 1 2 3 4 5 6 7 s = (r – rmin) + smin
rmax – rmin
n
Number of pixels 50 0 60 0 50 20 0 10 7
bl kn
s = (r – 0) + 0
3
When, r = 0, s = 0
at
Pu ch
7
r = 1, s = (1 – 0) = 2.3 2
3
7
r = 2, s = (2 – 0) = 4.67 5
Te
3
7
r = 3, s = (3 – 0) = 7
3
We have,
r=0 s=0
r=1 s=2
r=2 s=5
r=3 s=7
Hence the histogram tends to spread out as shown in
Fig. P. 8.2.2 (a).
Fig. P. 8.2.1
ge
for y1=1:1:col
c(x1,y1)=constant*(a(x1,y1)-w)+cmin;
io led
end
end
ic ow
for n=1:1:row
at
for m=1:1:col
Pu ch
h(12)
end
end (b) Image after histogram stretching
figure(1), bar(h)
% Plotting histogram of the modified image %
c=c+1;
h=zeros(1,400);
for n=1:1:row
for m=1:1:col
t=round(c(n,m));
h(t)=h(t)+1;
end
end
figure(2),bar(h)
figure(3),imshow(uint8(a))
figure(4),imshow(uint8(c)) (c) Original histogram
We know, s = T(r)
What is this T which produces equal values in each grey
level ?
The transformation that we are looking for must
satisfy the following two conditions :
(a) T(r) must be single valued and monotonically
increasing in the interval 0 r 1 and
(b) 0 T(r) 1 for 0 r 1 i.e., 0 s 1 for 0 r 1
Here the range of r is taken as [0, 1]. This is called the
normalized range. This range is taken for simplicity. So
instead of r being in the range [0, 255] we take [0, 1]
(d) Linear stretched histogram Let us see what these two conditions :
Fig. 8.2.3
ge
(1) If T (r) is not single valued. Refer Fig. 8.3.2(a). Here r1
8.3 Histogram Equalization and r2 are mapped as a single grey level s1 i.e., two
different grey levels look the same in the modified
io led
Linear stretching is a good technique but as mentioned image. This is a big drawback, hence the
earlier, the shape remains the same. transformation has to be single valued. This preserves
There are many applications, wherein we need a flat the order from black to white.
ic ow
histogram. This cannot be achieved by histogram A grey level transformation that is both single valued
stretching. and monotonically increasing is shown in Fig. 8.3.2(b).
n
We now introduce a new technique known as
bl kn
ps (s) = pr(r) dr …(8.3.1) Note : pr(r) is the PDF and hence cannot be greater
ds –1
r =T (s) than 1.
i.e., the probability density of the transformed image is Soln. :
equal to the probability density of the original image
From the diagram, we know that the above histogram
multiplied by the inverse slope of the transformation. represents a dark image.
We now need to find a transformation which would – r + 1 ;0r1
pr(r) =
give us a flat histogram. Let us consider the Cumulative 0 ; otherwise
Density Function (CDF). Cumulative density function is We shall use the CDF that we just discovered.
obtained by simply adding up all the Probability r r
Density Functions (PDF).
s = T (r) = pr (r)dr = (– r + 1) dr
s = T (r) 0 0
r –r
2
ge
0 2s = – r + 2r
2
ps(s) = [ 1 ] = 1; 0 s 1
i.e., ps(s) = 1 r = 1 1 – 2s ··· 0 r 1
n
This is nothing but a uniform density function !! r = 1 – 1 – 2s
bl kn
ps (s) =
ds ds
Pu ch
d
ps (s) = (– 1 + 1 – 2s + 1)
ds
{1 – (1 – 2s) 1/2}
d
Fig. 8.3.3 ps (s) = 1 – 2s
ds
{– (1 – 2s) 1/2}
A bad histogram becomes a flat histogram when we
∵ d (1) = 0
find the cumulative density function!! Let us cement this ds
concept by taking an examples. –1
1 – 2s (1 – 2s) (– 2)
–1/2
=
2
8.3.1 Solved Examples on Histogram 1
= 1 – 2s
Equalization 1 – 2s
ps (s)= 1 ;
Ex. 8.3.1 For the given histogram. Perform histogram Hence ps(s) = 1; 0 r 1.
equalization.
Fig. P. 8.3.1
Fig. P. 8.3.1(a)
DSIP (MU-Sem. 7-COMP) 8-8 Histogram Modelling
ge
Fig. P. 8.3.2 pr(rk)
So far, we have developed the technique of histogram 3 656 0.16 0.81 5.67 6
nk 7 81 0.02 1 7 7
pr (rk) =
n
Te
N = 4096
r
st nd
We know, s = T (r) = pr (r) We take 1 , 2 and the last column
0
Old grey level Equalized grey level New grey level
In the discrete domain,
r 0 790 1
sk = T (rk) = pr (r). This is the C. D. F
1 1023 3
0
Let us take up an example to see how this works in the 2 850 5
discrete domain. Some additional steps need to be taken
into account while working in the discrete domain. 3 656 6
4 329 6
Ex. 8.3.3 : Equalize the given histogram
Grey level 0 1 2 3 4 5 6 7 5 245 7
Number of 790 1023 850 656 329 245 122 81
pixels
6 122 7
Soln. : 7 81 7
L = 8 (Number of grey levels) We notice that the new grey levels have pixels only at
We first plot the original histogram 1, 3, 5, 6, 7. There are no pixels in grey levels 0, 2 and 4.
DSIP (MU-Sem. 7-COMP) 8-9 Histogram Modelling
ge
Old nk New grey levels New Modified
grey nk grey levels
io led levels
0 100 3 100 00
1 90 5 90 10
ic ow
2 50 6 50 2 0
n
Fig. P. 8.3.3(a) : Equalized histogram
3 20 7 3 100
bl kn
5 0 7 20 + 0 + 0 20 5 90
Pu ch
Fig. P. 8.3.4
Equalize Equalize again ? change in the histogram. Go ahead, try out your own
i.e. Dark historgram –––––– Flat historgram –––––––––––
examples. They will all give similar results.
We shall see what happens by considering an example.
Histogram equalization is guaranteed to yield exact
Ex. 8.3.5 : Given a histogram, see what happens when we results only in the continuous case. As the number of levels
decrease, the error between the specified and resulting
equalize it twice.
histogram increase and hence we do not get a flat
Grey level 0 1 2 3 histogram.
MATLAB code for histogram equalization
nk 70 20 7 3
%% Histogram equalization %%
Soln. : clear all
clc
nk
Grey nk pr (rk) = n sk = pr(rk) L=4 Rounding New nk a=imread(‘kids2.tif’);
level sk (L – 1) off % You can try the program with ‘pout.tif’%
ge
0 70 0.7 0.7 2.1 2 70
a=double(a);
big=max((max(a)));
1 20 0.2 0.9 2.7 3
%% Gives maximum value in the image
io led
2 7 0.07 0.97 2.91 3 20 + 7 + 3 [row col]=size(a);
C=row*col; %% Gives the total number of pixels required
3 3 0.03 1 3 3 = 30
ic ow
h=zeros(1,300);
L=4 100 %% Defining two arrays (h and z) to store the histogram
n
The modified grey levels are values
bl kn
z=zeros(1,300);
Grey level 0 1 2 3 for n=1:1:row
at
for m=1:1:col
Pu ch
nk 0 0 70 30
if a(n,m)==0
We now equalize this again. %% To ensure that the values of ‘a’ are not zero
Te
end
new=round(cdf*big); %% New is the new gray level
new=new+1; %% if new = 0, it is not to be taken in
the loop
for p=1:1:row
for q=1:1:col
temp=a(p,q);
b(p,q)=new(temp);
%% b has the equalized image %%
%% Plotting the equalised histogram %%
t=b(p,q);
%% Takes the value of the pixel example 12 %%
z(t)=z(t)+1; %% Incrementing the corresponding
counter z(12)%%
ge
end
end
io led
b=b-1;
%% Since we had initially incremented the value of n %% (b) Image after histogram equalization
%% Plotting %%
ic ow
ge
processing the given image in the following way.
Suppose pr(r) and ps(s) represent grey level PDFs of
io led
input and output images and r and s are their
respective grey levels. Suppose k represents grey level
of some intermediate image result i.e.,
ic ow
r s
k = T1 (r) = pr (r) dr and k = T2 (r) = ps (s)ds
n
0 0
bl kn
result. The procedure of histogram specification can Now equalize (a) as well as (b)
be computed as follows : Histogram (a) : L = 8
Te
(1) Equalize the levels of the original image. Grey nk pr (rk) = CDF = CDF Rounding New
nk pr(rk)
(2) Specify the desired density function and obtain level off grey
n
the transformation function. level
(L – 1)
(3) Apply the inverse transformation function.
0 790 0.19 0.19 1.33 1 790
Note that there are 5 distinct levels after histogram 8.5 Solved Examples on Histogram
equilization of histogram (a) Modelling
Grey 0 1 2 3 4 5 6 7
level Ex. 8.5.1 : Two images can have the same histogram
Number 0 790 0 1023 0 850 985 448 (Justify/ Contradict with reason). MU - Dec 2017, 5 Marks
of pixels Soln. :
ge
2 0 0 0 0 0
same in both the images. Hence two images can have the
3 614 0.149 0.149
io led 1.05 1 same histogram.
4 819 0.20 0.35 2.45 3
5 1230 0.30 0.65 4.55 5
ic ow
Ex. 8.5.2 : What effect would setting to zero the lower order
To obtain histogram specification, we apply the bit planes have on the histogram of an image in general ?
at
Fig. P. 8.4.1(c) 12 13 14 15
Hence the final result is as shown Histogram of the original image is as shown in
Fig. P. 8.5.2.
Grey 0 1 2 3 4 5 6 7
Number 0 0 0 790 1023 850 985 448
of pixels
Hence we see that histogram (a) has been equalized
and mapped in such a way that it resembles the histogram
(b). This is histogram specification.
Fig. P. 8.5.2
DSIP (MU-Sem. 7-COMP) 8-14 Histogram Modelling
We convert the original image to a binary image. Since Comparing this histogram with the original histogram,
the maximum grey level is 15, we need 4-bits for its we see that the variability is reduced, i.e. number of grey
representation. levels are reduced and the height of these grey levels has
increased.
0000 0001 0010 0011
Ex. 8.5.3 : What would be the effect on the histogram if we
0100 0101 0110 0111 set to zero, the higher order bit planes.
Soln. :
1000 1001 1010 1011 Proceeding in a similar manner as in Ex. 8.5.2 and
working with the same image, we get
1100 1101 1110 1111
Converting to binary
ge
4 5 6 7 0100 0101 0110 0111
0000 0000 0000 0000
8 9 10 11 1000 1001 1010 1011
io led
0100 0100 0100 0100
12 13 14 15 1100 1101 1110 1111
Converting back to the grey level format we get, 0000 0000 0000 0000 0 1 2 3
at
0 0 0 0
1000 1000 1000 1000 0 1 2 3
4 4 4 4
Te
Soln. :
In this we form an image by taking the modulus of the difference of the spatial coordinates. The image that is formed
using the equation f(x,y) = |x – y| is shown below :
0 1 2 3 4 5 6 7
0 0 1 2 3 4 5 6 7
1 1 0 1 2 3 4 5 6
2 2 1 0 1 2 3 4 5
f(x, y) = 3 3 2 1 0 1 2 3 4
4 4 3 2 1 0 1 2 3
ge
5 5 4 3 2 1 0 1 2
6 6 5 4 3 2 1 0 1
io led
7 7 6 5 4 3 2 1 0
ic ow
Number of pitch 8 14 12 10 8 6 4 2
at
Pu ch
Fig. P. 8.5.4
DSIP (MU-Sem. 7-COMP) 8-16 Histogram Modelling
ge
6 4 0.062 0.966 6.762 7
7 2 0.031 1 7 7
io led
nk= 64
ic ow
n
bl kn
st nd
We consider the 1 , 2 and last column
at
0 8 1 8
Te
1 14 2 14
2 12 4 12
3 10 5 10
4 8 6 8 + 6 14
5 6 6
6 4 7 4+2 6
7 2 7
Grey levels 0 1 2 3 4 5 6 7
nk 0 8 14 0 12 10 14 6
ge
io led
Fig. P. 8.5.4(a)
ic ow
2 3 4 2 m = 4, l = 3.5 4
at
m = 5, l = 5.25 5
Pu ch
5 5 2 4
m = 6, l = 7
3 6 3 5
The modified image is
Te
5 3 5 5 0 2 4 0
5 5 0 4
2 7 2 5
5 2 5 5
Fig. P. 8.5.5
Soln. :
We draw the original histogram of the image.
Fig. P. 8.5.5(b)
ge
equalization to achieve edge sharpening and contrast
Grey nk PDF CDF sk (L – 1) Round
enhancement. Does it matter which of the two processes are
level nk i.e., i.e., sk 7 off
applied first ? pr (k) =
n
io led sk =
Soln. :
pr(k)
High frequency emphasis is the same as a high boost
filter. Let us see what we get when we apply a high 0 0 0 0 0 0
ic ow
6 50 0.05 1 7 7
s = T [g (x, y)] 7 0 0 1 7 7
s = T [f (x, y) * h (x, y)] …(1)
n = 1000
If we decide to apply histogram equalization prior to st nd
Consider the 1 , 2 and last column
high boost filter, we get
ge
Gray 0 1 2 3 4 5 6 7 We now draw the original as well as the equalized
level histogram.
No. of 128 75 280 416 635 1058 820 684
io led
Pixel
ic ow
(MU - May 2011, Dec. 2012, 10 Marks) (a) Original histogram (b) Equalized histogram
Soln. : Fig. P. 8.5.8
at
Pu ch
7 684 0.1670 1 7.00 7 Q. 1 Plot the graph of a cumulative density function (CDF).
Grey 0 1 2 3 4 5 6 7
Number of pixels 50 0 50 0 50 0 50 0
ge
Q. 5 Suppose that a image is subjected to a histogram
0 1 2
equalization. Show that a second pass of histogram
equalization will produce exactly the same result as
io led 3 4 5
the first pass.
6 7 8
Q. 6 What are the two conditions that a transformation has
ic ow
9 Segmentation
Syllabus :
Segmentation based on Discontinuities (point, Line, Edge), Image Edge detection using Robert, Sobel, Previtt masks,
Image Edge detection using Laplacian Mask. Connectivity
ge
May 2016, Dec. 2016, Dec. 2018, 2 Marks (computer). The computer scans the slide and based
on certain algorithms classifies them as RBC’s,
Q. What is image segmentation
WBC’s....etc.
io led
(May 2016, Dec. 2016, Dec. 2018, 2 Marks) We hence needed to do image segmentation to divide
Segmentation, as the name suggests, subdivides the image into various parts.
(segments) an image into its constituent regions or (2) Finger print matching in forensic studies
ic ow
This simply means we endeavour to find out what is in Now if there has been a crime at a place and some
at
Pu ch
the picture. Segmentation forms a section of computer finger prints have been found, images are taken, and
vision i.e., we use segmentation, when we want the these images are run through an algorithm to see if
computer to make decisions. this particular finger print matches with the one in the
Te
ge
–1 2 –1 –1 2 –1
which have properties to detect these discontinuities.
–1 2 –1 –1 –1 2
9.2.1 Point Detection
io led
Vertical – 45
Remember one thing, points, lines and edges are all
high frequency components and hence we need masks We notice that all these masks have a sum equal to
ic ow
which are basically high pass. Hence the masks that we zero, and hence all of them are high pass masks. The
present here for point, line and edge detection have first mask would respond strongly to lines that are
n
the properties of a high mask mainly, the sum of the oriented horizontally. The second mask would respond
bl kn
coefficients of the mask has to be equal to zero in all to lines at an angle of + 45, the third mask would
the three cases. respond strongly to vertical lines and the last mask
would respond strongly to lines at an angle of 45.
at
high pass mask for it. And so that this mask detects
only points and not lines, we set a threshold value i.e.,
Te
–1 –1 –1
–1 8 –1
–1 –1 –1
|R| T …(9.2.1) Fig. 9.2.1
Where R is derived from the standard convolution Let us take a simple example of a 8 8 pseudo image.
formula
0 0 0 10 0 0 0 0
R = w1 z1 + w2 z2 + ...........+ w9 z9
9 0 0 0 10 0 0 0 0
R = wi zi 0 0 0 10 0 0 0 0
i=1
0 0 0 10 0 0 0 0
We take |R| because we want to detect both the kinds
of points i.e. white points on a black background as 0 10 10 10 10 10 10 0
well as black points on a white background. 0 0 0 10 0 0 0 0
T is a non negative threshold which is defined by the
0 0 0 10 0 0 0 0
user.
0 0 0 10 0 0 0 0
DSIP (MU-Sem. 7-COMP) 9-3 Segmentation
It is quite evident that in this image we have two lines, We see that the horizontal mask detects lines only in
one horizontal and the second vertical. the horizontal direction and cleans up the other lines
Let us see what happens when we move the first (vertical line in this case).
(Horizontal) mask over the image. By now you should In a similar fashion we can show that vertical, + 45,
be quite comfortable with moving masks on the entire and – 45 masks respond strongly to lines in their
image. We leave the borders and hence start from the respective directions. It would be a good idea to try
encircled pixel. this out yourself.
The result that we obtain is as shown
9.2.3 Edge Detection
0 0 0 0 0 0 0 0 More than isolated points and lines, it is the detection
0 0 0 0 0 0 0 0 of edges that form an important part of image
segmentation. An edge can be defined as a set of
0 0 0 0 0 0 0 0
connected pixels that form a boundary between two
0 – 20 – 20 – 20 – 20 – 30 – 20 0 disjoint regions.
ge
0 + 40 + 40 + 40 + 40 + 60 + 40 0 A typical example of an edge is shown in Fig. 9.2.2.
0 – 20 – 20 – 20
io led
– 20 – 30 – 20 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
ic ow
These values are made zero as was discussed in Here the set of pixels that separate the black region
chapter of Image Enhancement in Spatial Domain. from the grey region is called an edge. The line profile
at
Pu ch
Hence the final image obtained as follows, of such an edge is shown along with edge.
The image shown has a step edge. Such step edges
0 0 0 0 0 0 0 0
occur only in artificially generated images such as test
Te
Fig. 9.2.3
It is this anti-aliasing filter which reduces the slope of the edge. Due to this, real world images when captured through
a camera will not have step edges. In practice, edges are modelled as having a ramp like profile.
DSIP (MU-Sem. 7-COMP) 9-4 Segmentation
Fig. 9.2.4
Here the slope of the ramp is inversely proportional to the degree of blurring.
Given below are some of the two dimensional, discrete domain edge models.
a a a a a b b b b b a a a b b b b b b b
a a a a a b b b b b a a a a b b b b b b
a a a a a b b b b b a a a a a b b b b b
ge
a a a a
io led a b b b b b a a a a a a b b b b
a a a a a b b b b b a a a a a a a b b b
a a a a a a a a a a a a a a c b b b b b
a a a a a a a a a a a a a a c b b b b b
n
bl kn
a a a a a b b b b b a a a a c b b b b b
a a a a a b b b b b a a a a c b b b b b
at
Pu ch
a a a a a b b b b b a a a a c b b b b b
a a c b b b b b b b a a a a a a a a a a
a a a c b b b b b b a a a a c c c c c c
a a a a c b b b b b a a a a c b b b b b
a a a a a c b b b b a a a a c b b b b b
a a a a a a c b b b a a a a c b b b b b
a a a a c b b b b b a a d e b b b b b b
a a a a c b b b b b a a a d e b b b b b
a a a a c b b b b b a a a a d e b b b b
a a a a c b b b b b a a a a a d e b b b
a a a a c b b b b b a a a a a a d e b b
a a a a a a a a a a
a a a a d c c c c c
a a a a c b b b b b
a a a a c b b b b b
a a a a c b b b b b
Fig. 9.2.5
If we now want to plot the derivative image, we need
9.3 Detection of Edges
to take the magnitude of Fig. 9.3.1(c). This gives us
ge
How do these edges come in an image ? Fig. 9.3.1(d). As can be seen, we get non-negative
Variation of scene features, usually brightness, give values only at the two edges of the image. We can
io led
rise to edges. In other words, edges are thus conclude that computing the derivative helps us
representations of the discontinuities of the scene in detecting the edges.
intensity function. Although this discussions has been limited to the
ic ow
There could be various reasons such as type of 1-D horizontal profile, a similar argument applies to an
material, surface texture, lighting conditions, etc., edge of any orientation in an image.
n
which play an important role in forming these
The first derivative at any point in an image is obtained
bl kn
discontinuities.
by using the magnitude of the gradient at that point.
Our aim in this chapter is to detect these
at
computation of the local derivative operator. the gradient. This discussion will help us understand edge
Consider the image shown in Fig. 9.3.1. detection better.
Case 1 : Output is a function of one variable
(Example : 1-dimensional signal) y = f(x).
We know that the derivative of y w.r.t. x is
dy lim f (x + h) – f(x)
= h0 = f (x)
dx h
dy
The slope is dx
Fig. 9.3.1
Fig. 9.3.1 shows that the first derivative of the grey line
profile is positive at the leading edge of a transition,
negative at the trailing edge and zero in areas of
Fig. 9.3.2
constant grey levels.
DSIP (MU-Sem. 7-COMP) 9-6 Segmentation
ge
f lim f (x, y + k) – f(x, y) f
= k0 = Rate of change of ‘f’ w.r.t the y-direction
y k y
io led
f
is the rate of change of f w.r.t. y keeping
y
ic ow
x constant.
Hence the final gradient is
n
^ f ^ f
F = i
bl kn
+j ...(9.3.1)
x y
Fig. 9.3.4
at
Pu ch
Corel 2
Fig. 9.3.3
f lim f (x + h, y) – f(x, y)
Case 3 : Output is a function of three variables We know, =
x h0 h
(3-dimensional, e.g.. Density at different points in
f lim f (x, y + k) – f(x, y)
the atmosphere or pressure at different points) =
0
y k k
(Not useful in image processing)
In the discrete domain, h = k = 1
P = f(x, y, z)
f
= f(x + 1, y) – f (x, y)
the three partial derivatives are x
f lim f (x + h, y, z) – f(x, y, z) f
= h0 and = f(x, y + 1) – f (x, y)
x h y
f lim f (x, y + k, z) – f(x, y, z)
= k0
y k
DSIP (MU-Sem. 7-COMP) 9-7 Segmentation
ge
io led
Corel 3
ic ow
Ordinary masks
| F | = | Z5 Z8 | + | Z5 Z6 |
Roberts masks
| F | = | Z5 Z9 | + | Z6 Z8 | …(9.4.2)
(a) Original image (b) X-gradient image
ge
The results of the Roberts mask are shown along with
the program.
io led
The sum of the two Roberts masks is
1 1
ic ow
clc
(2 2). Masks of even sizes are awkward to implement.
aa=imread(‘cameraman.jpg’);
Note that the differential along the diagonals of a 2 2
Te
a=double(aa); mask is used and the edge value after the convolution
[row col]=size(a);
corresponds to the central point r – 2 c – 2 .
1 1
w1= [1 0; 0 -1];
w2= [0 1; -1, 0]; This problem can be avoided using 3 3 masks.
for x=2:1:row-1;
Prewitts Operator
for y=2:1:col-1;
a1(x,y)=w1(1)*a(x,y)+w1(2)*a(x,y+1)+w1(3)*a(x+1,y) Prewitt J.M.S in his paper “Object Enhancement and
+w1(4)*a(x+1,y+1); Extraction” in 1970 came up with a 3 3 mask. The Prewitt
a2(x,y)=w2(1)*a(x,y)+w2(2)*a(x,y+1)+w2(3)*a(x+1,y) operator, as is now called, while approximating the first
+w2(4)*a(x+1,y+1); derivative, assigns similar weights to all the neighbours of
end the candidate pixel whose edge strength is being
end calculated.
a3=a1+a2; %% Final Gradient Image %% F | (Z7 + Z8 + Z9) (Z1 + Z2 + Z3) | + | (Z3 + Z6 + Z9) (Z1 + Z4 + Z7) |
figure(1) …(9.4.3)
imshow(uint8(a1)) %% The x-gradient image, you might
x-gradient y-gradient
need normalization
figure(2) From this equation, the masks that we obtain are
imshow(uint8(a2)) %% The y-gradient image, you might
need normalization
figure(3)
imshow(uint8(a3)) %% Final image %%
DSIP (MU-Sem. 7-COMP) 9-9 Segmentation
–1 –2 –1 –1 0 1 –2 –2 0
0 0 0 + –2 0 2 = –2 0 2
1 2 1 –1 0 1 0 2 2
Fx Fy Fx + Fy
Duda R.O and Hart P.E in 1973 published a paper %% Prewitts operator %%
“Pattern Classification and Scene Analysis” in which they clear all
used a new operator known as the Sobel Operator. clc
In the Sobel Operator higher weights are assigned to aa=imread(‘test.tif’);
the pixels close to the candidate pixels.
a=double(aa);
ge
F | (Z7 + 2Z8 + Z9) (Z1 + 2Z2 + Z3)| + | (Z3 + 2Z6 + Z9) (Z1 + 2Z4 + Z7) |
[row col]=size(a);
w2=[-1 0 1;-1 0 1;-1 0 1];
io led
x-gradient y-gradient
w1=[-1 -1 -1; 0 0 0; 1 1 1];
…(9.4.4)
for x=2:1:row-1;
for y=2:1:col-1;
n
a1(x,y)=w1(1)*a(x-1,y-1)+w1(2)*a(x-1,y)
bl kn
Corel 8
+w1(3)*a(x-1,y+1)+w1(4)* …
at
a(x,y-1)+w1(5)*a(x,y)+w1(6)*a(x,y+1)
Pu ch
ge
io led
(a) Original image (b) X-gradient image
(c) Y-gradient image (d) Resultant gradient image
ic ow
Fig. 9.4.3
n
MATLAB code for Sobel operator
bl kn
%% Sobel operator %%
clear all
at
Pu ch
clc
aa=imread(‘warne.tif’);
a=double(aa);
Te
[row col]=size(a);
(c) Y-gradient image (d) Resultant gradient image
w1=[-1 -2 -1; 0 0 0; 1 2 1 ];
Fig. 9.4.4
w2=[-1 0 1; -2 0 2; -1 0 1 ];
for x=2:1:row-1; Both results can be obtained using absolute values.
for y=2:1:col-1; Have you noticed one thing that is common to all the
a1(x,y)=w1(1)*a(x-1,y-1)+w1(2)*a(x-1,y) edge detection masks that we have studied so far ?
+w1(3)*a(x-1,y+1)+w1(4)* … Let us draw all the masks together.
a(x,y-1)+w1(5)*a(x,y)+w1(6)*a(x,y+1) 1 0 1 –1 1 0 0 1
+w1(7)*a(x+1,y-1)+w1(8)* …
a(x+1,y)+w1(9)*a(x+1,y+1); –1 0 0 0 0 –1 –1 0
a2(x,y)=w2(1)*a(x-1,y-1)+w2(2)*a(x-1,y) Ordinary operator Robert’s operator
+w2(3)*a(x-1,y+1)+w2(4)* …
a(x,y-1)+w2(5)*a(x,y)+w2(6)*a(x,y+1) –1 –1 –1 –1 0 1 –1 –2 –1 –1 0 1
+w2(7)*a(x+1,y-1)+w2(8)*
…a(x+1,y)+w2(9)*a(x+1,y+1); 0 0 0 –1 0 1 0 0 0 –2 0 2
end 1 1 1 –1 0 1 1 2 1 –1 0 1
end
Prewitt mask Sobel mask
a3=a1+a2; %% Final gradient values %%
figure(1)
imshow(uint8(a1)) %% The x-gradient image,
DSIP (MU-Sem. 7-COMP) 9-11 Segmentation
Sum of the coefficients of each of these masks is Hence the Prewitt operator performs uniform
zero !! smoothing in one direction with edge detection in the
This is a very important property to note. Edges are perpendicular direction.
abrupt discontinuities in the gray levels and hence are In a similar manner, we can split up the Sobel operator
high frequency regions. Since the sum of the into smaller and simpler operators.
coefficients of all these masks is zero, they eliminate
all the low frequency components of the image i.e., i.e –1 –2 –1 –1
when these masks are placed on low frequency 0 0 0 = 0 1 2 1
regions, the output is zero. Hence these masks give
1 2 1 1 LP
edges without any low frequency regions in the final
output image. HP
Derivative filters (Gradient filters), as the name and –1 0 –1 1
suggests, calculate the gradient of the image. –2 0 2 = 2 –1 0 1
Since noise is also high frequency, the derivative of the
ge
1 0 1 1 HP
noise terms will always be large values and hence
derivative filters are very sensitive to noise.
io led LP
There is a huge advantage in using Prewitt and Sobel One can verify this by comparing the results of a
masks for edge detection. Both these operators Prewitt/ Sobel filter with that of standard highpass
provide a smoothing effect along with providing filter on an image corrupted by Gaussian noise. (Use
ic ow
noise !!
It is seen that edges in the horizontal as well as in the
How do they achieve this ? vertical direction are enhanced when Prewitt’s or Sobel’s
at
Pu ch
Let us consider the Prewitt operator Fx and Fy operator is used. There are applications, in which we need
edges in all the directions. A simple method would be to
–1 –1 –1 –1 0 1 rotate the Prewitts or Sobel’s mask in all the possible
Te
0 0 0 and –1 0 1 directions.
Considering a Prewitts operator
1 1 1 –1 0 1
i.e. –1 –1 –1 –1
0 0 0 = 0 1 1 1
We move this mask in the anticlockwise direction to
1 1 1 1
get all other masks
–1 –1 –1 –1 –1 0 –1 0 1 0 1 1
and –1 0 1 1
0 0 0 –1 0 1 –1 0 1 –1 0 1
–1 0 0 = 1 –1 0 1
1 1 1 0 1 1 –1 0 1 –1 –1 0
–1 0 1 1
In 1 1 1 is a low pass or a –1 0 1 1 1 1 1 1 0 1 0 –1 0 –1 –1
this smoothing operator,
0 0 0 1 0 –1 1 0 –1 1 0 –1
while
–1 –1 –1 0 –1 –1 1 0 –1 1 1 0
is a high pass operator.
DSIP (MU-Sem. 7-COMP) 9-12 Segmentation
–1 –1 –1 C(x,y)=[c(1)*I(x-1,y-1)+c(2)*I(x-1,y)
0 0 0 +c(3)*I(x-1,y+1)+c(4)*I(x,y-1) …
+c(5)*I(x,y)+c(6)*I(x,y+1)+c(7)*I(x+1,y-1)
1 1 1
+c(8)*I(x+1,y)+c(9)*I(x+1,y+1)];
This operator is known as the compass operator and is
very useful for detecting weak edges. D(x,y)=[d(1)*I(x-1,y-1)+d(2)*I(x-1,y)
Compass operators can also be implemented using the +d(3)*I(x-1,y+1)+d(4)*I(x,y-1)+ …
Sobel operator. d(5)*I(x,y)+d(6)*I(x,y+1)+d(7)*I(x+1,y-1)
%% Program of compass operator %% +d(8)*I(x+1,y)+d(9)*I(x+1,y+1)];
clear all, clc E(x,y)=[e(1)*I(x-1,y-1)+e(2)*I(x-1,y)
aa=imread(‘lily.tif’); +e(3)*I(x-1,y+1)+e(4)*I(x,y-1) …
I=double(aa); +e(5)*I(x,y)+e(6)*I(x,y+1)+e(7)*I(x+1,y-1)
ge
s=size(I); io led +e(8)*I(x+1, y)+e(9)*I(x+1,y+1)];
e=[d(1,2) d(1,3) d(2,3); d(1,1) d(2,2) d(3,3); d(2,1) d(3,1) +g(8)*I(x+1,y)+g(9)*I(x+1, y+1)];
d(3,2)]
Te
H(x,y)=[h(1)*I(x-1,y-1)+h(2)*I(x-1,y)
f=[e(1,2) e(1,3) e(2,3); e(1,1) e(2,2) e(3,3); e(2,1) e(3,1)
+h(3)*I(x-1,y+1)+h(4)*I(x,y-1) …
e(3,2)]
+h(5)*I(x,y)+h(6)*I(x,y+1)+h(7)*I(x+1,y-
g=[f(1,2) f(1,3) f(2,3); f(1,1) f(2,2) f(3,3); f(2,1) f(3,1) 1)+h(8)*I(x+1,y)+h(9)*I(x+1, y+1)];
f(3,2)]
end
h=[g(1,2) g(1,3) g(2,3); g(1,1) g(2,2) g(3,3); g(2,1) g(3,1)
end
g(3,2)]
W=max(max(max(max(max(max(max(A,B),C),D),E),F),G),
for x=2:1:s(1)-1;
H); %% To calculate maximum
for y=2:1:s(2)-1;
%% Plotting %%
A(x,y)=[a(1)*I(x-1,y-1)+a(2)*I(x-1,y)
figure(1),imshow(uint8(A)),figure(2),imshow(uint8(B))
+a(3)*I(x-1,y+1)+a(4)*I(x,y-1)+ …
figure(3),imshow(uint8(C)),figure(4),imshow(uint8(D))
a(5)*I(x,y)+a(6)*I(x,y+1)+a(7)*I(x+1,y-1)
figure(5),imshow(uint8(E)),figure(6),imshow(uint8(F))
+a(8)*I(x+1,y)+a(9)*I(x+1,y+1)];
figure(7),imshow(uint8(G)),figure(8),imshow(uint8(H))
B(x,y)=[b(1)*I(x-1,y-1)+b(2)*I(x-1,y)
figure(9),imshow(uint8(W)),figure(10),imshow(uint8(I))
+b(3)*I(x-1,y+1)+b(4)*I(x,y–1) …
+b(5)*I(x,y)+b(6)*I(x,y+1)+b(7)*I(x+1,y-1) %% Normalisation may be required %%
+ b(8)*I(x+1,y)+b(9)*I(x+1,y+1)];
DSIP (MU-Sem. 7-COMP) 9-13 Segmentation
ge
io led
ic ow
n
bl kn
at
Resultant image
Pu ch
2 +
x y
2
Second Derivative - the Laplacian
| F | = [f(x + 1, y) + f(x 1, y) + f(x, y + 1)
We have already seen the effects of using the first
derivative of the image. It was shown that the first + f(x, y 1) 4f(x, y)] ...(9.5.1)
derivative does enhance the edges of the image. We
now try to find out the effects of computing the Considering the 3 3 neighbourhood
second derivative on the edges.
y–1 y y+1
We know,
x–1 Z1 Z2 Z3
f f
F = +
x y x Z4 Z5 Z6
f
= f(x + 1, y) f(x, y) and x+1 Z7 Z8 Z9
x
f This equation in the discrete form reduces to,
= f(x, y + 1) f(x, y)
y
| F | = [Z8 + Z2 + Z6 + Z4 4Z5]
2
f
Where 2 = f(x + 1, y) + f(x – 1, y) – 2f(x, y) and
x C-11(a)
f
2 = f(x, y + 1) + f(x, y – 1) – 2f(x, y)
y
DSIP (MU-Sem. 7-COMP) 9-14 Segmentation
This is known as the Laplacian operator. Some books (1) Since the Laplacian is a second derivative filter, it
reverse the signs of the coefficients of the mask i.e., is very sensitive to noise (much more than the
first derivative). Hence in an image, if there is any
C-11(b) noise present, the Laplacian gives very large
values and ruins the entire image.
(2) The magnitude of the Laplacian produces double
edges, which is an undesireable effect. Let us
There might be cases when, we would need to add explain what we mean by double edges. Consider
higher weights at the center pixel (>4). While doing a strip of image shown in Fig. 9.5.1. It is seen that
nd
this we must make sure that the sum of the the magnitude of the 2 derivative produces two
coefficients of the mask is zero since edges are high peaks for a single edge.
frequency components. Hence if we increase the The zero crossing property of the Laplacian is
weights at the centre, we would also have to change used to detect edges.
the values of the coefficients at the borders.
ge
9.5.1 Laplacian of Gaussian Operator
As stated earlier, the Laplacian mask evokes very
io led
strong response to stray noise pixels. Hence if some
kind of noise cleaning is done prior to the application
of the Laplacian operator, better results could be
ic ow
ge
r – – r2/22
2 2
2
2 h(r) = e lap(5)*a(x,y)+lap(6)*a(x,y+1)
r
4
+lap(7)*(x+1,y-1)+lop(8)*a(x+1,y)+...
r – 4 e– r2/22
2 2
lap(9)*a(x+1,y+1)];
h =
io led …(9.5.3)
%% Calculating the Laplacian of a Gaussian %%
This is the Laplacian of a Gaussian (LoG). h can be dee(x,y)=log(1)*a(x-2,y-2)+log(2)*a(x-2,y-1)
easily plotted using MATLAB. Due to the shape of the +log(3)*a(x-2,y)+log(4)*a(x-2,y+1)+…
ic ow
+log(11)*a(x,y 2)+log(12)*a(x,y-1)+...
log(13)*a(x,y)+log(14)*a(x,y+1)+log(15)*a(x,y+2)
at
Pu ch
+log(16)*a(x+1,y-2)+...
log(17)*a(x+1,y-1)+log(18)*a(x+1,y)
Te
+log(19)*a(x+1, y+1)+log(20)*a(x+1,y+2)+…
log(21)*a(x+2,y-2)+log(22)*a(x+2,y-
1)+log(23)*a(x+2,y)+log(24)*a(x+2,y+1)+...
log(25)*a(x+2,y+2);
Fig. 9.5.2
end
It can be seen that h has a large positive value at the end
centre and negative values at the peripheries. %% Thresholding the output of the LoG operator %
We can approximate this by using a 5 5 mask as for x=1:1:row-2
shown. for y=1:1:col–2
if dee(x,y)<40
Remember, this mask is not unique. We could use any
deep(x,y)=0;
values that approximate the shape of the LoG.
else
One thing that needs to be kept in mind is that since
deep(x,y)=255
our intention is to enhance the edges, the sum of
end
coefficients of the mask should be zero.
end
0 0 –1 0 0 end
%%%%%%%%%%%%%%%%%%%%%%%%%
0 –1 –2 –1 0
%%%%%%%%ZERO CROSSINGS%%%%%%%%%%
–1 –2 16 –2 –1 for x=2:1:row-2
0 –1 –2 –1 0 for y=2:1:col-2
a1=deep(x,y);
0 0 –1 0 0
a2=deep(x-1,y-1);
DSIP (MU-Sem. 7-COMP) 9-16 Segmentation
ge
figure(1),imshow(uint8(a)) %% Original image
figure(2),imshow(uint8(c)) %% Only Laplacian
figure(3),imshow(uint8(dee)) %% LoG
io led
figure(4),imshow(uint8(deep)) %% LoG+Threshold
figure(5),imshow(uint8(deepa)) %% Zero crossings (a) A ramp edge, (b) First derivative of ramp edge, (c)
Second derivative of ramp edge
ic ow
n
bl kn
at
Pu ch
9.6 Connectivity
p(x – 1, y)
p(x + 1, y)
N4(p)
This set of eight pixels (The 4-neighbours as well as the Corel 16
diagonal pixels) is called the 8-neighbourhood of pixel
p(x, y) and is denoted as N8(p)
N8 (p)= N4(p) + ND(p).
Corel 17
Connectivity is an important concept that is used in
segmentation. When we started off with this chapter,
it was stated that segmentation is used for machine Let us take an example. Given the criteria that p = q = 1
vision.
ge
for the region to be connected, check whether the two
p(x –1, y – 1) p(x –1, y + 1) region S1 and S2 are connected.
Even though p and q are both equal to one, these two
io led
p(x, y)
regions will not be shown connected, if we use a 4-
p(x + 1, y – 1) p(x + 1, y + 1) connectivity algorithm. This is because, in the 4-
connectivity algorithm, we only check the 4-
ic ow
ND(p)
neighbours and see if any of these four neighbours has
In segmentation, the machine (computer) scans the
a pixel with the same value 1, in this case
n
image to form different regions. This scanning of the
bl kn
use 8-connectivity.
Two regions that touch only at a corner can be
considered to be a single region or two distinct Let us take an example.
regions : How they are considered depends on the Consider the image shown.
definition of connectivity used ?
Two pixels p and q with some common criteria are said
Corel 18
to be 4-connected if they share a side. i.e., two pixels p
and q with some common criteria are 4-connected if q
is in the set N4(p).
Here the condition used is that pixels belong to a
region if their value is 2.
When we use 8-connectivity here, we get
Corel 19
ge
9.6.1 Solved Example on Connectivity
Ex. 9.6.1 : Consider two image subsets S1 and S2
io led Corel 22
S1 S2
0 0 0 0 0 0 0 0 2 2
2 0 0 2 0 0 2 0 0 2 for a 3 3 region, we have the Euclidian distance as
ic ow
2 0 0 2 0 2 2 0 0 0 (2) City Block Distance (D4 Distance) : For the same points
n
0 0 2 2 2 0 0 0 0 0 p(x1, y1) and q(x2, y2), the city block distance is defined
bl kn
as
0 0 2 2 2 0 0 2 2 2 DCITY (p, q) = D4(p, q) = |x1 x2| + |y1 y2|
at
Pu ch
For V = {2}, determine whether S1 and S2 are The city block distance measures the path between
(a) 4-connected (b) 8-connected (c) m-connected the pixels based on a 4-connected neighbourhood.
Te
Soln. : Pixels whose edges touch are 1 unit apart and pixels
touching diagonally are 2 units apart.
V = {2} simply means that two pixels p and q are
connected if their values are equal to 2.
S1 S2
Corel 23
0 0 0 0 0 0 0 2 2 0
2 0 0 2 0 0 2 0 0 2
(3) Chess Board Distance (D8 Distance) : For pixels p(x1,
2 0 0 2 0 2 q 2 0 0 0 y1) and q(x2, y2), the chess board distance is defined as
0 0 2 2 2 p 0 0 0 0 0 DCHESS, (p, q) = D8 (p, q) = max(|x1 x2|, |y1 y2|)
The chessboard distance measures the path between
0 0 2 2 2 0 0 2 2 2
the pixels based on a 8-connected neighbourhood.
(a) S1 and S2 are not 4-connected because q is not in the Pixels whose edges or corners touch are 1 unit apart.
set of N4(p).
2 2 2 2 2
(b) S1 and S2 are eight connected because q is in the set of
N8(p). 2 1 1 1 2
(4) Dm Distance (m-adjacency Distance) : This distance (b) D8(p, q) = max (|x1 x2|, |y1 y2|)
measure is based on m-adjacency. Pixels p and q are = max (|4 0|, |0 4|)
m-adjacent if
= max (4, 4) = 4
(a) q is in N4(p) or
(b) q is in ND(p) and N4(p) ⋂ N4(q) is empty. Ex. 9.7.3 : Consider the image segment shown
3 1 2 1q
9.7.1 Solved Examples on Distance for V = {0, 1}, compute the
2 2 0 2
Transform length of the shortest
1 2 1 1 m-path between p and q.
Ex. 9.7.1 : Measure the Dm distance between p and q for the
1p 0 1 2
following images.
Soln. : The path taken is shown below :
Soln. :
ge
io led
Hence the shortest m-distance is equal to 5.
ic ow
Corel 25
ge
0 –1 0
required direction is zero.
Hence each mask would yield a value of 0 when –1 4 –1
io led
centered on a pixel of an unbroken 3-pixel segment 0 –1 0
oriented in the direction of the required mask. The
response of the mask would be +2 when the mask is
ic ow
Soln. :
Applying the mask we get,
We have seen that
2
Te
r
r –
2
h (r) = +
– 2
2
e
Corel 31
What we need to prove is
2
2 r
–
r 2 –
e 2 dr = 0
Case 2 : Image Rotate Convolve with Laplacian mask
–
2 2 Rotating image we get,
r r
1 – –
2 dr – 1
2 2
2
r e
e 2 dr = 0
– –
ge
and the Laplacian operation for the rotated –
coordinates are, f(x, y) f(x, y) = 5 {1.2 f(x, y) – f (x, y)}
–
f f
f
2
= 2 +
io led Here f (x, y) denotes the average of f(x, y) .
x y
2
= · + · = –
x x x y x x y
f(x, y) f(x, y) f(x, y) – f (x, y)
We take the partial derivative of this expression again
n
The RHS is the equation for unsharp masking. Hence
with respect to x
bl kn
subtracting the Laplacian from an image is equivalent to
f f f unsharp masking.
2 cos +
2
2 = sin cos
x x x y
at
Pu ch
f f 2 Ex. 9.8.7 : Segment the following image into two regions
+ cos sin + 2 sin …(1)
y x y based on the edge-orientations derived through a gradient
Te
–1 0 1 0 1 1 0 0 0 0
M3 = –1 0 1 M4 = –1 0 1 0 5 –5 – 18
–1 0 1 –1 –1 0 E = f M5 =
0 0 – 15 – 33
0 2 –8 – 18
1 1 1 1 1 0
M5 = 0 0 0 M6 = 1 0 –1 0 0 0 0
–1 –1 –1 0 –1 –1 0 8 1 –9
F = f M6 =
0 15 6 – 13
1 0 –1 0 –1 –1 0 27 23 0
M7 = 1 0 –1 M8 = 1 0 –1
ge
1 0 –1 1 1 0 0 0 0 0
0 7 10 6
io led
Let the original image be f (x, y).
G = f M7 =
While convolving we ignore the corner pixels. 0 19 25 12
0 36 45 18
0 0 0 0
ic ow
0 –5 5 18
0 0 0 0
n
A = f M1 =
0 0 15 33
bl kn
0 –1 9 15
0 –2 8 18 H = f M8 =
at
0 11 29 31
Pu ch
0 0 0 0 0 21 37 24
Te
0 0 36 45 24
DSIP (MU-Sem. 7-COMP) 9-23 Segmentation
Hence we have two regions, one being the zero region Q. 3 Explain edge detection in detail.
(say a) and the other being the non-zero region (say b).
Q. 4 Show that the Laplacian operator is invariant to
a a a a a rotation.
ge
analysis systems. It is imperative to understand the set of 3 H 3 masks that can be used to detect 1-pixel
applications of image segmentation. Segmentation long breaks in these lines. Assume that the grey level
partitions an image into meaningful regions having certain of the lines is 1 and that of the background is 0.
io led
characteristics unique to that region. In this, the output is
Q. 8 Explain the concept of compass operators.
an abstract representation of the input image. There exists
no general segmentation algorithm which will work Q. 9 Explain whether poorly illuminated image can be
ic ow
which forms an important topic of edge linking. (b) City block distance
(c) Chess board distance
Review Questions
(d) Dm distance.
Te
Pu ch
bl kn
ic ow
Note
at
io led
n ge