LAB MANUAL Lab Name : FPGA LAB Lab Code : 8CS6 Branch : Computer Engineering Year : 4 th Year 1
LAB MANUAL
Lab Name : FPGA LAB
Lab Code : 8CS6
Branch : Computer Engineering
Year : 4th Year
Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
(Rajasthan Technical University, KOTA)
1
INSTRUCTIONS OF LAB
DO’S
1. Student should get the record of previous experiment checked before starting the new
experiment.
2. Read the manual carefully before starting the experiment.
3. Before starting the experiment, get circuit diagram checked by the teacher.
4. Before switching on the power supply, get the circuit connections checked.
5. Get your readings checked by the teacher.
6. Apparatus must be handled carefully.
7. Maintain strict discipline.
8. Keep your mobile phone switched off or in vibration mode.
9. Students should get the experiment allotted for next turn, before leaving the lab.
DON’TS 1. Do not touch or attempt to touch the mains power supply wire with bare
hands.
2. Do not overcrowd the tables.
3. Do not tamper with equipments.
4. Do not leave the lab without permission from the teacher.
Jitendra Gautam
2
INSTRUCTIONS TO THE STUDENTS
GENERAL INSTRUCTIONS
Maintain separate observation copy for each laboratory.
Observations or readings should be taken only in the observation copy.
Get the readings counter signed by the faculty after the completion of the
experiment.
Maintain Index column in the observation copy and get the signature of the
faculty before leaving the lab.
BEFORE ENTERING THE LAB
The previous experiment should have been written in the practical file,
without which the students will not be allowed to enter the lab.
The students should have written the experiment in the observation copy
that they are supposed to perform in the lab.
The experiment written in the observation copy should have aim,
apparatus required, circuit diagram/algorithm, blank observation table (if
any), formula (if any), programme (if any), model graph (if any) and space
for result.
WHEN WORKING IN THE LAB
Necessary equipments/apparatus should be taken only from the lab
assistant by making an issuing slip.
Never switch on the power supply before the permission from the faculty.
BEFORE LEAVING THE LAB
The equipments/components should be returned back to the lab assistant in
good condition after the completion of the experiment.
The students should get the signature from the faculty in the observation
copy.
3
They should also check whether their file is checked and counter signed in the index.
INDEX
S.NO CONTENTS PAGE NO.
1 SYLLABUS 8
2. PROGRAM EDUCATIONAL OBJECTIVES 9
3. INTRODUCTION THEORY OF LAB 22
4. LIST OF EXPERIMENTS (RTU SYLLABUS)
Exp:- 1 Objectives :- Fundamental Theory
Introduction to DSP architectures and programming. Sampling Theory,
Analog-to-Digital Converter (ADC), Digital-to- Analog Converter
(DAC), and Quantization; Decimation, Interpolation, Convolution,
Simple Moving Average; Periodic Signals and harmonics;
Fourier Transform (DFT/FFT), Spectral Analysis, and time/spectrum
representations; FIR and IIR Filters;
Exp:- 1.a OBJECTIVE: Plotting of various elementary signals
like impulse function, unit step function, ramp function,
quadratic function, sine wave,and a general sinusoidal
function.
30
Exp:- 1.b OBJECTIVE: Verification of sampling theorem. 36
Exp:- 1.c OBJECTIVE: Derive the Impulse response of a given
system..
40
Exp:- 1.d OBJECTIVE: Perform linear convolution of two given
sequences.
43
4
Exp:- 1.e OBJECTIVE: Perform Circular convolution of two
given sequences.
46
Exp:- 1.f OBJECTIVE: Computation of N-point DFT of a given
sequence and to plot magnitude and phase spectrum.
48
Exp:- 1.g OBJECTIVE: Computation of Linear Convolution
using DFT & IDFT.
50
Exp:- 1.h OBJECTIVE: Down sampling or decimation of the
sum of two sinusoids by a factor M.
53
Exp:- 1.i OBJECTIVE: . To study the design and implementation of FIR filter to meet given specifications
56
Exp:- 1.j OBJECTIVE: To study the design and implementation
of IIR(LPF/HPF) filter to meet given specifications.
65
Sample Viva Question 69
Exp:2 Objectives :- Design (Simulation) using MATLAB/ Simulink
Simulate the lab exercises using MATLAB/Simulink
Exp:- 2.a OBJECTIVE: Realising a given block diagram having
multiplier, adder/subtractor and system with given
Impulse response. Calculating output for given input.
71
Exp:- 2.b OBJECTIVE: To simulate the transmitter and receiver
for BPSK.
78
Exp:- 2.c OBJECTIVE: Evaluate a second-order differential
equation.
81
Exp:- 2.d OBJECTIVE : To study Sigma-Delta A/D Conversion 83
5
Sample Viva Question 86
Exp:- 3 Implementation using pure DSP, pure FPGA and Hybrid DSP/FPGA
platforms. Digital Communications: On-Off- Keying (OOK), BPSK
modulation, and a simple transceiver design. Wireless
Communications: Channel coding/decoding, Equalization, Simple
Detection Algorithm, OFDM. Speech Classification and Synthesis
Exp:- 3.a OBJECTIVE : To study the basic introduction of
architecture of TMS320C6XXX DSP kits using Bloom
with DSP.
88
Exp:- 3.b OBJECTIVE: To study the architecture of
TMS320C6XXX DSP kit.
93
Exp:- 3.c OBJECTIVE: To perform linear convolution using DSP
processor.
112
Exp:- 3.d OBJECTIVE: To implement circular convolution of two
sequences using DSP processor.
125
Exp:- 3.e OBJECTIVE : To compute N-Point DFT of a given
sequence using DSP Processor.
140
Exp:- 3.f OBJECTIVE: To find Impulse response of a first order
and second order LTI system using DSP processor.
153
Sample Viva Question 168
5. LIST OF EXPERIMENTS (BEYOND SYLLABUS)
Exp:-
4.a
OBJECTIVE: Implementation of Transfer function of Log Gabor Filters.
170
Sample Viva Question 174
Exp:-
4.b
OBJECTIVE: Removal of noise from image signals using various spatial filtering operations.
175
6
Sample Viva Question 179
Exp:-
4.c
OBJECTIVE: Write a program in MATLAB to Remove noise from
an image signal using various spatial filtering operations.
180
Sample Viva Question 183
Exp:-
4.d
OBJECTIVE: Wavelets, wavelet transform and wavelet
decomposition.
184
Sample Viva Question 189
Exp:-
4.e
OBJECTIVE: Write a program in MATLAB to decompose an image
signal using Discrete Wavelet Transform.
190
Sample Viva Question 192
7
Swami Keshvanand Institute of Technology, Management & Gramothan
SYLLABUS
8CS6 FPGA LAB. (Comp. Engg.):
List of Experiments:
1. Fundamental Theory Introduction to DSP architectures and programming Sampling
Theory, Analog-to-Digital Converter (ADC), Digital-to- Analog Converter (DAC),
and Quantization; Decimation, Interpolation, Convolution, Simple Moving Average;
Periodic Signals and harmonics; Fourier Transform (DFT/FFT), Spectral Analysis,
and time/spectrum representations; FIR and IIR Filters;
2. Design (Simulation) using MATLAB/ Simulink. Simulate the lab exercises using
MATLAB/Simulink.
3. Implementation using pure DSP, pure FPGA and Hybrid DSP/FPGA platforms.
Digital Communications: On-Off- Keying (OOK), BPSK modulation, and a simple
transceiver design. Adaptive Filtering: Echo/Noise Cancellation, Least Mean
Square (LMS) algorithm . Wireless Communications: Channel coding/decoding,
Equalization, Simple Detection Algorithm, OFDM. Speech Processing: Prediction
Algorithms, Speech Classification and Synthesis.
8
Swami Keshvanand Institute of Technology, Management & Gramothan
PROGRAM EDUCTION OBJECTIVES AND OUTCOMES
Branch: Computer Engineering Semester: 8th
Course Name: FPGA Lab. Code: 8CS6
External Marks: 40 Practical hrs: 3 hrs/week
Internal Marks: 60
Total Marks: 100 1. PROGRAM OBJECTIVES:-
i. Preparation:- To prepare to pursue advanced graduate studies in computing or
related disciplines and provide students broad-based education in core areas of
Computer Science, including theoretical foundations, algorithms and data structures,
and computer hardware, with an appropriate blend of theory and practice and to
specialize in a variety of areas of Computer Science through a selection of elective
courses.
ii. Core Competence:-To provide students with a solid foundation in computer
engineering field required to solve computing problems using various programming
languages and softwares, and students can solve problems through logical and
analytical thinking.
iii. Breathe:-To train students with good computer and engineering breadth so as to
comprehend, analyze, design, and create novel products and solutions for the real
life.
9
iv. Professionalism:-To inculcate in students professional and ethical attitude, effective
communication skills, teamwork skills, multidisciplinary approach, and an ability to
relate computer engineering issues to broader social context.
v. Learning Environment:-To provide students with an academic environment aware
of excellence leadership and lifelong learning needed for successful professional
career through independent studies, thesis, internships etc.
2. PROGRAM OUTCOMES:-
a) Graduates will demonstrate knowledge of mathematics, science & Computer
Engineering and will develop ability to apply fundamental principles of computing,
mathematics and sciences as appropriate to the discipline of computer science.
b) Graduates will demonstrate an ability to identify formulate and solve Computer
Engineering problems and analyze a problem and model it as a computing system
using appropriate methodologies.
c) Graduates will demonstrate an ability to design and conduct experiments, analyze
and interpret data.
d) Graduates will develop ability to design a system, component or process implement
and test a computer application and to evaluate and compare the efficiencies of
alternative solutions as per the needs and specifications.
e) Graduates will develop an ability to visualize and work on laboratory and
multidisciplinary class.
f) Graduates will demonstrate skills to use modern engineering tools softwares and
equipments to analyze problems.
g) Graduates will demonstrate knowledge of professional and ethical responsibilities.
h) Graduates will able to communicate effectively in both verbal and written form.
i) Graduate will show the understanding of impact of Computer engineering solutions
on the society and also be aware of contemporary issues.
j) Graduate will develop confidence for self education and ability for lifelong learning.
k) Graduate can participate and succeed in competitive examinations like GATE etc.
10
3. MAPPING:-
PROGRAM
OBJECTIVES
PROGRAM OUTCOMES
A b C D E f G h i j k
I X x x
II X x X X x X
III x X X X
IV X X x x
V x x
4) Course Educational Objective:-
After studying FPGA LAB practical in their graduation plan student will be able
to:
i. Apply the knowledge to manage and to handle various signal based applications
like extraction/modification of information in a signal, to solve the real world
problems.
ii. Gain a repudiated designation as good signal processing manager and
administrator ethically by applying signal processing software technologies.
iii. Be successfully accepted in future’s development scenario as an engineering
graduate pursuit of lifelong learning.
iv. Exhibit team spirit management & effective signal processing dealings.
11
v. Can give better emerging computer based techniques and ideas to analyze design
implement industry based on FPGA module development.
vi. The FPGA experiments attempts to provide practical knowledge of applications in
digital signal processing using FPGA and DSP platforms used in real world for
extracting information from signals.
vii. It provides the convenient environment for the development of chips/modules
used to process signals in various electronic systems according to our
requirements.
5) Course Outcomes (student learning outcomes ):
Each student learning outcome (SLO) maps to one of the program education
objective (PEO) as indicates in parentheses following the outcomes.
Graduate of the program will:
1. Implementation and understanding of DSP and FPGA circuits/modules.
2. They are able to understand the difference among various DSP applications.
3. Implement proficiency in using and developing various DSP application
softwares according to market demand.
4. Can show their ability to apply conceptual skills in signal processing.
5. Graduates will show interest towards the development of different modern and
efficient tool (MATLAB and CCStudio 3.)
6. Graduates will able to know about the programming as well as block diagram
implementation of a DSP system using MATLAB and SIMULINK of a DSP
system.
7. Implement different types of DSP applications and use of them.
8. By understanding it, graduate will be able to design and implement existing, as
well as innovative system designs in DSP.
9. They will introduce the concepts of using DSP processor kit and interfacing it
with computer software.
12
.
6. COURSE OBJECTIVES CONTRIBUTION TO PROGRAM OUTCOMES:-
Students who have successfully completed this course will have full understanding of following
concepts:-
COURSE OBJECTIVE PROGRAM OUTCOME
i. Apply the knowledge to manage
and to handle various signal based
applications like extraction/
modification of information in a
signal, to solve the real world
problems.
b) Graduates will demonstrate an
ability to identify formulate and
solve Computer Engineering
problems and analyze a problem
and model it as a computing system
using appropriate methodologies.
c) Graduates will demonstrate an
ability to design and conduct
experiments, analyze and interpret
data.
d) Graduates will develop ability to
design a system, component or
process implement and test a
computer application and to
evaluate and compare the
efficiencies of alternative solutions
as per the needs and specifications.
i) Graduate will show the
understanding of impact of
Computer engineering solutions on
the society and also be aware of
contemporary issues.
j) Graduate will develop confidence
ii. Gain a repudiated designation as
good signal processing manager
and administrator ethically by
applying signal processing software
technologies.
iii. Be successfully accepted in future’s
development scenario as an
engineering graduate pursuit of
lifelong learning.
iv. Exhibit team spirit management &
effective signal processing
dealings.
v. Can give better emerging computer
13
based techniques and ideas to
analyze design implement industry
based on FPGA module
development
for self education and ability for
lifelong learning.
vi. The FPGA experiments attempts to
provide practical knowledge of
applications in digital signal
processing using FPGA and DSP
platforms used in real world for
extracting information from signals.
1. Graduates will demonstrate skills to
use modern engineering tools
software and equipments to analyze
problems.
MAPPING OF COURSE OBJECTIVE WITH PROGRAM OUTCOMES
SLOs/PEOs A b C D E f G H i j K
1 x X
2 X x
3 x
4 x x
5 X X x
6 x X
7 x x
14
7. TOPICS COVERED BEYOND THE CURRICULUM:- With the topics in the
syllabus the following topics will be covered in this subject which are important
for FPGA lab:
Uni
tBeyond Syllabus topic Source
I
To study the Transfer
function of Log Gabor
Filters
At Bandwidth limitations of Gabor filters
The Log-Gabor Filter Applications of log-
Gabor filters
.www.csse.uwa.edu.au/~pk/research/matlabfns/.../
convexpl.html
II
Removal of noise from image signals using various spatial filtering operations.
Concept of image. Noise in images Filtering methods to
remove noise
Gonzales R.C., Woods R.E. Digital Image
Processing, (2ndedition). Prentice Hall Publication.
III
Remove noise from an image
signal using various spatial
filtering operations using
MATLAB
MATLAB Image Processing Toolbox.
IV Wavelets, wavelet transform Gonzales R.C., Woods R.E. Digital Image
15
and wavelet decomposition Processing, (2ndedition). Prentice Hall Publication.
V
Decompose an image signal
using Discrete Wavelet
Transform using MATLAB.
MATLAB Wavelet Toolbox
8. BOOKS:-
Text books:
1. Getting started with MATLAB 7-By Rudra Pratap
-Chapman
2. Digital signal processing
By S Salivahanan
.
Reference Books :
Digital signal processing
- By Farookh Hussain
Communication Systems
- By Sanjay Sharma
Digital signal processing -By B.P.Lathi
Introduction to Simulink with Engineering Applications- Steven T. Karris
16
9. INSTRUCTIONAL METHODS:-
9.1. Direct Instructions:
I. Black board presentation
II. PowerPoint presentation
III. Multimedia like video lectures
9.2. Interactive Instruction:
I. Think, pair, share
II. Quiz
9.3 Indirect Instructions:
I. Problem solving
9.4 Independent Instructions:
Assignments
10) LEARNING MATERIALS:-
1. Text/lecturer notes/ lecturer PPT
2 .Multimedia material (videos, text with animations)
3. Web Resources:-
www.mathworks.com www.matlab.com www.dsplaboratory.com www.matrixlab.com
12) ASSESSMENT OF OUTCOMES:-
1. Sessional tests (two in each semester and assessment is done on the basis of
average of marks.
2. End term exam (Conducted by RTU, KOTA)
3. Surprise Quiz/ Tests.
4. Presentation by students.
5. Daily class room interaction.
17
6. Assignments.
7. Online Exam(Two exams in each semester)
13). OUTCOMES WILL BE ACHIEVED THROUGH FOLLOWING:-
1. Class room teaching (through chalk and board /PPT).
2. Discussion on case- studies.
3. Video lectures through NPTEL, MATHWORKS.
LIST OF PROGRAMS
18
S. NO. TITLE PAGE NO
1.a Write a program for plotting of various elementary signals like impulse function, unit step function, ramp function, quadratic function, sine wave,and a general sinusoidal function.
30
1.b Write a program for verification of sampling theorem. 36
1.c Write a program to derive the Impulse response of a given system. 40
1.d Write a program to perform linear convolution of two given sequences.
43
1.e Write a program to perform Circular convolution of two given sequences.
46
1.f Write a program for computation of N-point DFT of a given
sequence and to plot magnitude and phase spectrum.
48
1.g Write a program for computation of Linear Convolution using DFT & IDFT.
50
1.h Write a program for Down sampling or decimation of the sum of
two sinusoids by a factor M.
53
1.i Write a program to study the design and implementation of FIR filter to meet given specifications
56
1.j Write a program to study the design and implementation of
IIR(LPF/HPF) filter to meet given specifications.
65
2.a Realising a given block diagram having multiplier, 71
19
adder/subtractor and system with given Impulse response.
Calculating output for given input using SIMULINK
2.b To simulate the transmitter and receiver for BPSK using SIMULINK.
78
2.c Evaluate a second-order differential equation using SIMULINK.. 81
2.d To study Sigma-Delta A/D Conversion using SIMULINK. 83
3.a To study the basic introduction of architecture of TMS320C6XXX DSP kits using Bloom with DSP.
88
3.b To study the architecture of TMS320C6XXX DSP kit. 93
3.c Write a program to perform linear convolution using DSP processor.
112
3.d Write a program to implement circular convolution of two sequences using DSP processor.
125
3.e Write a program To compute N-Point DFT of a given sequence using DSP Processor.
140
3.f Write a program to find Impulse response of a first order and second order LTI system using DSP processor.
153
PROGRAMS BEYOND THE SYLLABUS
4 Implementation of Transfer function of Log Gabor Filters. 170
5 Removal of noise from image signals using various spatial filtering operations.
175
6 Write a program in MATLAB to Remove noise from an image signal using various spatial filtering operations.
180
20
7 Wavelets, wavelet transform and wavelet decomposition. 184
8 Write a program in MATLAB to decompose an image signal using Discrete Wavelet Transform.
190
INTRODUCTION THEORY OF LAB
21
General instructions for the students regarding MATLAB:-
1. Always prefer M-files to write the programs in MAT-LAB.
2. Save the M-files with .m extension.
3. Do not save the file with the name which resembles to any predefined function in
the MATLAB.
4. Always refer to the MATLAB help while using any new function or in case of
confusion.
5. Clear the command window while running any new program by giving the clear
command, because it generates confusion.
6. To see the diagrammatic result refer to the figure window of MATLAB.
7. In case of slow processing, don’t press the ‘run button’ or any other button again
and again. Give it some time to recover.
8. Save the programs on each turn and simultaneously prepare the file, it will save
your time.
9. Never use numbers while saving the programs.
22
INTRODUCION TO MATLAB
MATLAB
MATLAB stands for ‘MATRIX-LABORATORY’.
MATLAB is a high-level language and interactive environment that enables you to
perform computationally intensive tasks faster than with traditional programming
languages such as C, C++, and FORTRAN. MATLAB allows easy matrix manipulation,
plotting of functions and data, implementation of algorithms, creation of user interfaces
and interfacing with programs in other languages. MAT-LAB contains matrix which does
not require any dimensions so it is very easy to implement any program or any
algorithmmin a few dozen of lines with a great accuracy and with a great efficiency.
HISTORY OF MATLAB
MAT-LAB was invented in late 1970’s by ‘Cleve Moler’.he was the chair person of
computer science department at the university of New Mexico. He invented it to give the
direct access to linpak and eispak without learning fortranto his students. Very soon it
becomes very popular in other universities and in other communities. Jack Little an
engineer exposed to it when Cleve Moler made a visit to the Stanford University. Later
on realizing his potential he joined with Cleve Moler and Steve Bangertto rewroye the
MAT-LAB in ‘C’which is known as ‘math works’ in 1984. These rewritten libraries are
known as ‘jack-pack’.it was firstly used by control design engineers. This is a high-level
matrix/array language with control flow statements, functions, data structures,
input/output, and object-oriented programming features. It allows both "programming in
the small" to rapidly create quick and dirty throw-away programs, and "programming in
the large" to create large and complex programs. MATLAB has extensive facilities for
displaying vectors and matrices as graphs, as well as annotating and printing these
graphs. It includes high-level functions for two-dimensional and three-dimensional data
visualization, image processing, animation, and presentation graphics. It also includes
low-level functions that allow you to fully customize the appearance of graphics as well
as to build complete graphical user interfaces on your MATLAB applications. MATLAB
23
has evolved over a period of years with input from many users. In university
environments, it is the standard instructional tool for introductory and advanced courses
in mathematics, engineering, and science. In industry, MATLAB is the tool of choice for
high-productivity research, development, and analysis In MATLAB, a matrix is a
rectangular array of numbers. Special meaning is sometimes attached to 1-by-1 matrices,
which are scalars, and to matrices with only one row or column, which are vectors.
MATLAB has other ways of storing both numeric and nonnumeric data, but in the
beginning, it is usually best to think of everything as a matrix. The operations in
MATLAB are designed to be as natural as possible. Where other programming languages
work with numbers one at a time, MATLAB allows you to work with entire matrices
quickly and easily. A good example matrix, used throughout this book, appears in the
Renaissance engraving Melencolia I by the German artist and amateur mathematician
Albrecht Dürer.
How to get started
When the computer has started go through the following steps in the different menus
Look for the Network Applications folder and double click on that
Within this you will see a little icon for Matlab – double click on that
Within about 30 seconds Matlab will open.
Starting MATLAB
After logging into your account, you can enter MATLAB by double-clicking on the
MATLAB shortcut icon on your Windows desktop. When you start MATLAB, a special
window called the MATLAB desktop appears. The desktop is a window that contains
other windows. The major tools within or accessible from the desktop are:
The Command Window
The Command History
24
The Workspace
The Current Directory
The Help Browser
The Start button
Figure-1
25
MAT-LAB PRODUCT FAMILY:-
MAT-LAB has six members in its product family.
1. Technical computing –it includes the mathematical computation, data analysis,
algorithm development and vizualisation.
2. Control designing -it is a very good fascility provided in MAT-LAB.by using this
fascility we can design open loop and closed loop control systems, we can
analyse these systems by connecting different input signals to the input
port of the system.
3. Signal processing -it is also related with model designing. It includes the analysis of
different signals, which are applied to the input ports of different systems.
4. Image processing -it includes the processing of images and videos, analysis,
algorithm development and system design.the tools for image processing
in MAT-LAB gives a great help to scientists, researchers, astronauts in
the different disciplines such as medical imaging, aerospace, material
science.
5. Test and measurements - Test & Measurement solution provides a complete set of
tools for test, data analysis and modeling, and presentation-quality
reports, all in a single environment.
6. Modeling and simulation -this is a very good facsility provided in MAT-LAB.before
implementing any system in real time world, we can simulate it and can
see its response to the different inputs. According to its output we can
decide its merits and demerits. so before implementing the system in real
world , we can improve it with the help of simulation.
SIMULINK
Simulink is software for modeling, simulating, and analyzing Dynamic systems. It
26
supports linear and nonlinear systems, modeled in continuous time, sampled time, or a
hybrid of the two. Systems can also be multirate, i.e., have different parts that are
sampled or updated at different rates. Simulink is a software package that enables you to
model, simulate and analyze systems whose output changes over time. Such systems are
often referred to as dynamic systems. Simulink helps you to explore the behavior of a
wide range of real world dynamic systems including electrical circuits, shock absorbers
braking systems and many other electrical, mechanical and thermodynamic systems.
Simulating a dynamic system is a two step process. First the user creates a block diagram
using a simulink model editor that graphically depicts time dependent mathematical
relationship among the system’s input states and outputs. The user then commands
simulink to simulate the system represented by the model from a specified start time to a
specified stop time. Simulink enables you to pose a question about a system, model it,
and see what happens. With Simulink, you can easily build models from scratch, or take
an existing model and add to it. Thousands of engineers around the world use Simulink to
model and solve real problems in a variety of industries. Simulink turns your computer
into a lab for modeling and analyzing systems that simply wouldn't be possible or
practical otherwise, whether the behavior of an automotive clutch system, the flutter of an
airplane wing, the dynamics of a predator-prey model, or the effect of the monetary
supply on the economy. Simulink provides numerous demos that model a wide variety of
such real-world phenomena.
Block-sets
Block-sets are specialized collection of simulink blocks built for solving particular
problems. It gives the block presentation of the various control systems. Signal
processing block-sets is a tool for digital signal processing algorithm simulation and code
generation. All the blocks support double and single floating point data types. Most
blocks also support fixed point and integer data types when you have simulink fixed
point. You can interconnect signal processing block-sets block to create sophisticated
models capable of simulating operations such as speech and audio processing, wireless
digital communications, radar/sonar and medical electronics.
27
Simulink libraries
Simulink libraries are used to design the models. It contains the elements required to
construct a model of a system. It includes sources, sinks, mathematical operations,
transfer function blocks, feedback loops, various types of output devices and input
signals.
Figure 2-Simulink Library
Figure 3 -Simulink Library Browser
Here in the above figure you can see the sources which are generally connected to the
input port of the system. The second element is sink which are connected to the output
port of the system to plot the response of the system. The various transfer functions can
be written by using the continuous and discrete facility. The math operation provides the
28
mathematical expressions like product and addition. To make a model in MAT-LAB first
of all we have to open the simulink library browser. It gives the list of all the essential
elements required to construct a model. When we further open the listed elements they
will give us the detailed members of the respected families.
For example:-
Simulink library browser sources sine function
Unit step function
Sinks scope
Bode plotter
A SIMPLE BLOCK DIAGRAM:-
Figure-4- Simple block
In the above figure the input section contains the sine wave generator which is given to
the quantizer. The quantizer converts the continuous wave into the discrete levels. The
output can be seen in the scope.
TOOL-BOX
Control System Toolbox builds on the foundations of MATLAB to provide functions
designed for control engineering. Control System Toolbox is a collection of algorithms,
29
written mostly as M-files, that implements common control system design, analysis, and
modeling techniques. These are specialized collection of M-files built specifically for
solving particular classes of problems. For example:-
1. Filter design
2. Signal processing
EXPERIMENT NO-1.a
OBJECTIVE: Plotting of various elementary signals like impulse function, unit step
function, ramp function, quadratic function, sine wave,and a general sinusoidal function.
Theory:
Here we attempt to plot some elementary functions using MATLAB commonly used in
various applications in DSP . these functions are discussed below-
Impulse function:
The Dirac delta function, or Impulse function, is function that is zero everywhere
except at zero such that, The Dirac delta can be loosely thought of as a function on the
real line which is zero everywhere except at the origin, where it is infinite-
Figure-1.a.1- impulse function
Unit Step Function:
Unit Step function u(t) is one for all positive values, and zero for negative values of input.
30
u(t) useful for representing the opening or closing of switches
Figure-1.a.2 -step function
Ramp function:
In Ramp function, input is equal to output for positive values, and zero elsewhere.
Figure-1.a.3- Ramp function
Quadratic function:
This function is integral of ramp function, its non linear in nature.
31
Figure-1.a.4 – Quadratic function
Sine wave:
Sine wave is a sinusoidal function with a single frequency.
Figure-1.a.5 – Sine function
Sinusoidal function:
It is a sinusoidal function having two or more frequencies.
32
Figure-1.a.6 – Sinusoidal function
PROGRAM:
clear all;
close all;
clc;
t = (0:pi:100);
y = sin(2*pi*100*t);
y1 = sin(2*pi*10*t) + 2*sin(2*pi*50*t);
imp= [1; zeros(99,1)];
unit_step = ones(100,1);
ramp_sig= t;
quad_sig=t.^2;
subplot(3,2,1),stem(imp);
title('Impulse Function');
xlabel('time');
33
ylabel('Amplitude');
axis([-10 10 0 1])
subplot(3,2,2),stem(unit_step);
title('Unit step Function');
xlabel('time');
ylabel('Amplitude');
axis([-10 10 0 1]);
subplot(3,2,3),plot(t,ramp_sig);
title('Ramp Function');
xlabel('time');
ylabel('Amplitude');
subplot(3,2,4),plot(t,quad_sig);
title('Quadratic Function');
xlabel('time');
ylabel('Amplitude');
subplot(3,2,5),plot(t,y);
title('Sinusoidal function');
xlabel('time');
ylabel('Amplitude');
subplot(3,2,6),plot(t,y1);
title('y1');
34
xlabel('time');
ylabel('Amplitude');
Output:
35
EXPERIMENT NO-1.b
.
OBJECTIVE: Verification of sampling theorem.
Theory-
Sampling: Is the process of converting a continuous time signal into a discrete time
signal. It is the first step in conversion from analog signal to digital signal.
Sampling Theorem (Nyquist Theorem ): Sampling theorem states that “Exact
reconstruction of a continuous time base-band signal from its samples is possible, if the
signal is band-limited and the sampling frequency is greater than twice the signal
bandwidth”. i.e. fs > 2fm, where fm is the highest frequency present in that signal.
Nyquist Rate Sampling: The Nyquist rate is the minimum sampling rate required to
avoid aliasing, equal to the highest modulating frequency(fm) contained within the
signal. In other words, Nyquist rate is equal to two sided bandwidth of the signal (Upper
and lower sidebands). To avoid aliasing, the sampling rate must exceed the Nyquist rate.
i.e. fs > fm.
Aliasing: Aliasing is a phenomenon where the high frequency components of the
sampled signal interfere with each other, because of inadequate sampling fs < 2fm.
Aliasing leads to distortion in recovered signal. This process is called Undersampling.
This is the reason why sampling frequency should be at least twice the bandwidth of the
signal. In practice signal are oversampled, where fs is significantly higher than Nyquist
rate to avoid aliasing. . This process is called Oversampling.
Frequency spectrum of a signal which has undergone aliasing is shown below.
36
Figure-1.b.1 -Distortion due to undersampling(aliasing)
Program-
clear all;
close all;
clc;
tf=0.05;
t=0:0.00005:tf;
f=input('Enter the analog frequency,f = ');
xt=cos(2*pi*f*t);
fs1=1.3*f;
n1=0:1/fs1:tf;
xn=cos(2*pi*f*n1);
subplot(3,1,1),plot(t,xt,'b',n1,xn,'r*-');
title('Undersampling plot');
37
xlabel('time');
ylabel('Amplitude');
fs2=2*f;
n2=0:1/fs2:tf;
xn=cos(2*pi*f*n2);
subplot(3,1,2),plot(t,xt,'b',n2,xn,'r*-');
title('Nyquist plot');
xlabel('time');
ylabel('Amplitude');
fs3=20*f;
n3=0:1/fs3:tf;
xn=cos(2*pi*f*n3);
subplot(313),plot(t,xt,'b',n3,xn,'r*-');
title('Oversampling plot');
xlabel('time');
ylabel('Amplitude');
\
38
Output:
Enter the sampling frequency: 100
39
EXPERIMENT NO-1.c
OBJECTIVE: Derive the Impulse response of a given system..
Theory-
A discrete time system performs an operation on an input signal based on predefined
criteria to produce a modified output signal. The input signal x(n) is the system
excitation, and y(n) is the system response. The transform operation is shown as,
Figure-1.c.1 – Transform Operation
If the input to the system is unit impulse i.e. x(n) = δ(n) then the output of the system is
known as impulse response denoted by h(n) where,
h(n) = T[δ(n)]
Any arbitrary sequence x(n) can be represented as a weighted sum of discrete impulses.
Now the system response for a linear system is given by-
y(n) = Σx(k) T[δ(n-k)]
for k = - to .
The response to the shifted impulse sequence can be denoted by-
h(n- k) = T[δ(n-k)]
that implies that,
40
y(n) = Σx(k) h(n-k)
for k= - to .
That implies that for a linear time-invariant system if the input sequence is x(n) and
impulse response h(n) is given, we can fine output y(n) by using above equation, which is
known as convolution sum(discussed later) and can be represented by y(n) = x(n) * h(n).
Program-
clear all;
close all;
clc;
disp('Difference Equation of a digital system');
N=input('Desired Impulse response length = ');
b=input('Coefficients of x[n] terms = ');
a=input('Coefficients of y[n] terms = ');
h=impz(b,a,N);
disp('Impulse response of the system is h = ');
disp(h);
n=0:1:N-1;
figure(1);
stem(n,h);
xlabel('time index');
ylabel('h[n]');
title('Impulse response');
41
OUTPUT:
[Given y(n)-y(n-1)+0.9y(n-2)= x(n)]
Difference Equation of a digital system
Desired Impulse response length = 100
Coefficients of x[n] terms = 1
Coefficients of y[n] terms = [1 -1 0.9]
42
EXPERIMENT NO-1.d
OBJECTIVE: Perform linear convolution of two given sequences.
Theory: Convolution is an integral concatenation of two signals. It has many
applications in numerous areas of signal processing. The most popular application is the
determination of the output signal of a linear time-invariant system by convolving the
input signal with the impulse response of the system. Note that convolving two signals is
equivalent to multiplying the Fourier Transform of the two signals.
Mathematic Formula:
The linear convolution of two continuous time signals x(t) and h(t) is defined by-
For discrete time signals x(n) and h(n), is defined by
Where x(n) is the input signal and h(n) is the impulse response of the system.
In linear convolution length of output sequence is,
length(y(n)) = length(x(n)) + length(h(n)) – 1;
Graphical Interpretation:
Reflection of h(k) resulting in h(-k)
Shifting of h(-k) resulting in h(n-k)
Element wise multiplication of the sequences x(k) and h(n-k)
Summation of the product sequence x(k) h(n-k) resulting in the convolution
43
value for y(n).
Program:
clc;
x1 = input('Enter the 1st seq:');
x2 = input('Enter the 2nd seq:');
y = conv(x1, x2);
disp('The linear convolution of two sequences:');
disp(y);
n = 0:length(y)-1;
stem(n, y);
xlabel('Time');
ylabel('Magnitude');
title('Linear convolution');
Output:
Enter the 1st seq:[1 2 3 1]
Enter the 2nd seq:[1 1 1]
The linear convolution of two sequences:
1 3 6 6 4 1
44
EXPERIMENT NO-1.e
OBJECTIVE: Perform Circular convolution of two given sequences.
Theory:
Let x1(n) and x2(n) are finite duration sequences both of length N with DFT’s X1(k)
and X2(k). Convolution of two given sequences x1(n) and x2(n) is given by the
equation,
x3(n) = IDFT[X3(k)]
X3(k) = X1(k). X2(k)
Then,
where N stands for modulo operation.
45
Program:
clc;
x1 = input('Enter 1st seq:');
x2 = input('Enter 2nd seq:');
n = max(length(x1),length(x2));
x1 = fft(x1,n);
x2 = fft(x2,n);
y = x1.*x2;
yc = ifft(y,n);
disp('circular convolution:');
disp(yc);
N=0:1:n-1;
subplot(1,1,1);
stem(N,yc);
xlabel('Time');
ylabel('Magnitude');
title('Circular convolution');
axis([-1 5 0 15]);
OUTPUT:
Enter 1st seq:[1 1 2 1]
Enter 2nd seq:[1 2 3 4]
Circular convolution:
13 14 11 12
46
EXPERIMENT NO-1.f
OBJECTIVE: Computation of N-point DFT of a given sequence and to plot magnitude
and phase spectrum.
Theory:
Discrete Fourier Transform: The Discrete Fourier Transform is a powerful
computation tool which allows us to evaluate the Fourier Transform on a digital
computer or specially designed digital hardware. Since is continuous and
periodic, the DFT is obtained by sampling one period of the Fourier Transform at a finite
number of frequency points. Apart from determining the frequency content of a signal,
DFT is used to perform linear filtering operations in the frequency domain.
The sequence of N complex numbers is transformed into the sequence of N
complex numbers by the DFT according to the formula:
47
Program:
clc;
x1 = input('Enter the sequence:');
n = input('Enter the length:');
m = fft(x1,n);
disp('N-point DFT of a given sequence:');
disp(m);
N = 0:1:n-1;
subplot(2,1,1);
stem(N,m);
axis([-1 5 -10 10]);
xlabel('Length');
ylabel('Magnitude of X(k)');
title('Magnitude spectrum:');
an = angle(m)*180/pi;
subplot(2,1,2);
stem(N, an);
axis([-1 5 -180 180]);
xlabel('Length');
ylabel('Phase of X(k)');
title('Phase spectrum:');
Output:
Enter the sequence:[1 2 3 4]
Enter the length:4
N-point DFT of a given sequence:
48
10.0000 -2.0000 + 2.0000i -2.0000 -2.0000 - 2.0000i
EXPERIMENT NO-1.g
OBJECTIVE: Computation of Linear Convolution using DFT & IDFT.
Theory:
Convolution is an integral concatenation of two signals. It has many applications in
numerous areas of signal processing. The most popular application is the determination
of the output signal of a linear time-invariant system by convolving the input signal with
the impulse response of the system. Note that convolving two signals is equivalent to
multiplying the Fourier Transform of the two signals.
49
Mathematic Formula:
The linear convolution of two continuous time signals x(t) and h(t) is defined by:
For discrete time signals x(n) and h(n), is defined by
Where x(n) is the input signal and h(n) is the impulse response of the system.
For example, let us take two sequences, x1 and x2. For linear convolution, length of
output sequence x3 will be,
Length N(x3) = Length(x1) + Length(x2) - 1
Also, convolution of two sequences x1(n) and x2(n) is,
x3(n) = IDFT[X3(k)]
x3(n) = IDFT[X1(k) .X2(k)]
Where,
X1(k) = DFT [x1(n)]
X2(k) = DFT [x2(n)]
Where,
50
And,
Program:
clc;
x1 = input('Enter the 1st seq:');
x2 = input('Enter the 2nd seq:');
n = length(x1) + length(x2)-1;
x1 = fft(x1,n);
x2 = fft(x2,n);
y = x1.*x2;
yc = ifft(y,n);
disp('Linear convolution using DFT and IDFT:');
disp(yc);
N = 0:1:n-1;
stem(N,yc);
Axis([-1 4 -5 5]);
xlabel('Time');
ylabel('Magnitude');
title('Linear convolution using DFT and IDFT:');
Output:
Enter the 1st seq:[1 1 2]
51
Enter the 2nd seq:[1 2]
Linear convolution using DFT and IDFT:
1 3 4 4
Plot:
EXPERIMENT NO-1.h
OBJECTIVE: . Down sampling or decimation of the sum of two sinusoids by a factor
M.
THEORY:
Multirate Digital Signal Processing to change the sampling rate of a signal. Different
sampling rates can be obtained using upsampling and downsampling.
52
Decimation is for reducing the sampling rate and interpolation is for increasing
sampling rate of a signal. Decimation requires that aliasing should be prevented. Hence,
prior to down-samplingwith the factor of M, the original signal has to be bandlimited to
π/M. This means that the factor of M decimation has to be implemented in two steps:
(1) Bandlimiting of the original signal to π/M
(2) Down-sampling by the factor-of-M
Figure 1.1 shows the block diagram of a decimator implemented as a cascade of the
decimation filter H(z), also called the anti-aliasing filter, and the factor-of- M down-
sampler.
Figure 1.h.1- Factor-of- M down-sampler
Interpolation: The signal x(n) and its three fold upsampled signal y(n). In practice, the zero valued samples inserted by upsampler are replaced with approximate nonzero values using some type of filtering process. The process is called interpolation. This means that the factor-of-L interpolation has to be implemented in two steps:1. Up-sampling of the original signal by inserting L-1 zero-valued samples between twoconsecutive samples2.Replacing zero values from the non-zero values using interpolation.
To replace sampling rate of a signal by a fractional rate L/M , block diagram is shown as-
Figure 1.h.2- Factor-of- L/M sampling rate converter.
53
Program:
clc;
clear all;
close all;
N = input('Length of ip signal= ');
M = input('Dwnsmpling factor= ');
f1 = input('Freq. of first sinusoid= ');
f2 = input('Freq. of second sinusoid= ');
n = 0:N-1;
x = 2*sin(2*pi*f1*n)+ 3*sin(2*pi*f2*n);
y = decimate(x,M,'fir');
subplot(2,1,1);
stem(n,x(1:N));
title('Input sequence');
xlabel('Time');
ylabel('amplitude');
subplot(2,1,2);
m = 0:N/M - 1;
stem(m,y(1:N/M));
title(['output seq. dwn sampling factor ',num2str(M)]);
xlabel('Time');
ylabel('amplitude');
Output:
Length of ip signal= 100
Dwnsmpling factor= 4
Freq. of first sinusoid= 40
54
Freq. of second sinusoid= 60
EXPERIMENT NO-1.i
OBJECTIVE: . To study the design and implementation of FIR filter to meet given
specifications.
Theory:
55
Filters are the frequency selective circuit that passes a specified band of frequencies and
blocks or attenuates signals of frequencies outside this band.
Filters are broadly classified in a number of ways:-
1. Analog filters or Digital filters
2. Passive filters or Active filters
3. Audio frequency filters (A.F) or Radio frequency filters (RF)
Analog filter are designed to process analog signals, while digital filters process analog
signals using digital techniques.
Depending on the type of element used in their construction, filters may be classified as
passive or active. Elements used in passive filters are resistors, capacitors and inductors.
Active filters, on the other hand, employ transistors or op-amps in addition to the resistors
and capacitors. Depending on the frequency used the filters are classified as AF and RF.
The most commonly used filters are:-
1. low pass filter
2. high pass filter
3. band pass filter
4. band reject filter
5. all pass filter
A Finite Impulse Response (FIR) filter is a discrete linear time-invariant system
Whose output is based on the weighted summation of a finite number of past inputs.
An FIR transversal filter structure can be obtained directly from the equation for
Discrete-time convolution.
In this equation, x (k) and y (n) represent the input to and output from the filter at time
56
n. h(n-k) is the transversal filter coefficients at time n. These coefficients are
Generated by using FDS (Filter Design Software or Digital filter design package).
FIR – filter is a finite impulse response filter. Order of the filter should be specified.
Infinite response is truncated to get finite impulse response. Placing a window of
finite length does this. Types of windows available are Rectangular, Barlett,
Hamming, Hanning, Blackmann window etc. This FIR filter is an all zero filter.
Finite Impulse Response (FIR) Filter: The FIR filters are of non-recursive type,
whereby the present output sample is depending on the present input sample and previous
input samples. The transfer function of a FIR causal filter is given by-
Where h(n) is the impulse response of the filter.
The Fourier transform of h(n) is-
In the design of FIR filters most commonly used approach is using windows. The desired
frequency response of a filter is periodic in frequency and can be expanded in
Fourier series. The resultant series is given by,
And known as Fourier coefficients having infinite length. One possible way of obtaining
FIR filter is to truncate the infinite Fourier series at n =
Where N is the length of the desired sequence.
57
The Fourier coefficients of the filter are modified by multiplying the infinite impulse
response with a finite weighing sequence w(n) called a window.
Where w(n) = w(-n) for
= 0 for
After multiplying w(n) with hd(n), we get a finite duration sequence h(n) that satisfies the
desired magnitude response,
h(n) = hd(n).w(n) for
= 0 for
The frequency response of the filter can be obtained by convolution of
and is given by,
Program:
clear all;
close all;
clc;
rp=input('enter passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter passband freq');
fs=input('enter stopband freq');
f=input('enter sampling freq ');
wp=2*fp/f;
58
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end
c=input('enter your choice of window function 1. rectangular 2. triangular 3.kaiser: \n ');
if(c==1)
y=rectwin(n1);
disp('Rectangular window filter response');
end
if (c==2)
y=triang(n1);
disp('Triangular window filter response');
end
if(c==3)
y=kaiser(n1);
disp('kaiser window filter response');
end
%LPF
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);plot(o/pi,m);
59
title('LPF');
ylabel('Gain in dB-->');
xlabel('(a) Normalized frequency-->');
%HPF
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(o/pi,m);
title('HPF');
ylabel('Gain in dB-->');
xlabel('(b) Normalized frequency-->');
%BPF
wn=[wp ws];
b=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,3);plot(o/pi,m);
title('BPF');
ylabel('Gain in dB-->');
xlabel('(c) Normalized frequency-->');
%BSF
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,4);plot(o/pi,m);
title('BSF');
ylabel ('Gain in dB-->');
60
xlabel ('(d) Normalized frequency-->');
Output: enter passband ripple0.02
enter the stopband ripple0.01
enter passband freq1000
enter stopband freq1500
enter sampling freq 10000
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
61
1. Rectangular window filter response
2. Enter passband ripple0.02
enter the stopband ripple0.01
enter passband freq1000
enter stopband freq1500
enter sampling freq 10000
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
3. Triangular window filter response
62
3. Enter passband ripple0.02
enter the stopband ripple0.01
enter passband freq1000
enter stopband freq1500
enter sampling freq 10000
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
4. kaiser window filter response-
EXPERIMENT NO -1.j
63
OBJECTIVE : To study the design and implementation of IIR(LPF/HPF) filter to meet
given specifications.
Theory:
The IIR filter can realize both the poles and zeroes of a system because it has a
rational transfer function, described by polynomials in z in both the numerator and the
denominator:
The difference equation for such a system is described by the following:
M and N are order of the two polynomials
bk and ak are the filter coefficients. These filter coefficients are generated using
FDS(Filter Design software or Digital Filter design package).
IIR filters can be expanded as infinite impulse response filters. In designing IIR
filters, cutoff frequencies of the filters should be mentioned. The order of the filter
can be estimated using butter worth polynomial. That’s why the filters are named as
butter worth filters. Filter coefficients can be found and the response can be plotted.
Program:
64
clc;
clear all;
close all;
disp('enter the IIR filter design specifications');
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband freq');
ws=input('enter the stopband freq');
fs=input('enter the sampling freq');
w1=2*wp/fs;w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
c=input('enter choice of filter 1. LPF 2. HPF \n ');
if(c==1)
disp('Frequency response of IIR LPF is:');
[b,a]=butter(n,wn,'low','s');
end
if(c==2)
disp('Frequency response of IIR HPF is:');
[b,a]=butter(n,wn,'high','s');
end
w=0:.01:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
an=angle(h);
figure,subplot(2,1,1);plot(om/pi,m);
title('magnitude response of IIR filter is:');
xlabel('(a) Normalized freq. -->');
ylabel('Gain in dB-->');
subplot(2,1,2);plot(om/pi,an);
title('phase response of IIR filter is:');
xlabel('(b) Normalized freq. -->');
65
ylabel('Phase in radians-->');
Output:
Low Pass Partner-
enter the IIR filter design specifications
enter the passband ripple0.15
enter the stopband ripple60
enter the passband freq1500
enter the stopband freq3000
enter the sampling freq7000
enter choice of filter 1. LPF 2. HPF
1
Frequency response of IIR LPF is:
enter the IIR filter design specifications
enter the passband ripple0.15
66
enter the stopband ripple60
enter the passband freq1500
enter the stopband freq3000
enter the sampling freq7000
enter choice of filter 1. LPF 2. HPF
2
Frequency response of IIR HPF is:
67
Unit -1
Sample Viva Questions
Q.1 Define various elementary signals used in DSP applications, along with their
mathematical interpretion.
Q.2 Define sampling. State sampling theorm for perfect reconstruction of signal.
Q.Define aliasing? How aliasing is eliminated?
Q.3 What is nyquist sampling, oversampling and undersampling.
Q.4 What is a LTI system ? Define impulse response of an LTI system.
Q.5 What are FIR and IIR LTI systems?
Q. 6 Differentiate between recursive and non-recursive LTI systems?
Q.7What is linear convolution?
Q.8 Define circular convolution.
Q.9 What is difference between circular and linear convolution?
Q.10 What is Fourier Transform? Define discrete Fourier Transform.
Q.11 How linear convolution can be performed using DFT?
Q.12 Define Direct form I and Direct Form II network structures for IIR systems.
Q.13 Differentiate between Analog filters and Digital filters.
Q.14 Differentiate between Passive filters or Active filters.
Q.15 What is an IIR digital filter ?
68
Q.16 What is an FIR digital filter ?
Q.17 Compare IIR and FIR digital filters.
Q.18 Define window function.
Q.19 Discuss various types of window function used in the design of FIR digital filters?
Q.20 Define digital Butterworth filter.
Q.21 What is Multirate Digital Signal Proccessing?
Q.22 Differentiate between up-sampling and down-sampling.
Q.23 Define decimation and its significance.
Q. 24 Define interpolation and its significance.
Q. 25 Describe the sampling rate conversion by a rational factor L/M.
69
Implementation using Simulink
EXPERIMENT 2.a
OBJECTIVE
Realising a given block diagram having multiplier, adder/subtractor and system with
given Impulse response. Calculating output for given input.
THEORY-
70
71
72
Example-Given difference equation-y[n]= .75 y[n-1]- 0.125y[n-2]+ x[n]+2x[n-1]+x[n-
2]
73
Direct form 1 block diagram
Direct form 2 block diagram
74
Procedure for make block diagram-
1. Start matlab.
2. Open model option in new option.
3. A new window is open and in this new window open simulink library
browser.
4. Drag different blocks from library browser according to requirement.
5. Draw the block diagram.
6. Start the simulation.
7. Output can see in scope block that is same in case of direct form1 and direct
form2.
Simulink model-
We implement here, two Direct form 2, systems, with given transfer functions-
First one has a Transfer function-
Its block diagram is shown below-
75
OUTPUT:
If we give a square wave of amplitude 1, and frequency of 0.005 Hz, Input and output
waveforms for the model will be-
Second one has a Transfer function-
Its block diagram is-
A demo model using fixed−point Simulink blocks can be displayed by typing-
76
fxpdemo_direct_form2
in MATLAB’s Command Window. This demo is an implementation of the third−order
transfer function. Input and Output waveforms will be like-
77
EXPERIMENT 2.b
OBJECTIVE : To simulate the transmitter and receiver for BPSK.
SOFTWARE USED- MATLAB 7.5
THEORY-
BPSK-binary phase shift keying.
In BPSK modulation, the phase of the RF carrier is shifted 180 degrees in accordance
with a digital bit stream. The digital coding scheme used is called NRZ-M. A "one"
causes a phase transition, and a "zero" does not produce a transition. That way you don't
have to worry about the polarity of the signal. The receiver performs a differentially
coherent detection process, in which the phase of each bit is compared to the phase of the
preceding bit. Better performance can be obtained with fully coherent PSK, but that
requires an absolute phase reference at each end, and no phase variations in the
propagation path. Pretty hard to achieve, even on LF. Because the output of the receiver's
coherent detector swings from +V to -V when there's a phase transition, rather than from
+V to zero in the case of on-off keying, BPSK offers a 6-dB advantage in signal-to-noise
ratio over on-off keying for a given carrier level.
BPSK TRANSMITTER-
78
Simulink model-
BPSK RECEIVER-
79
Output of bpsk transmitter-
Outputs of bpsk receiver-
80
EXPERIMENT 2.c
OBJECTIVE : Evaluate a second-order differential equation.
THEORY-
Here we will evaluate a second-order, non-homogeneous differential equation with
constant coefficients, using simulink. We have a differential equation obtained by an
electrical circuit. Differential equation is-
Block diagram for the above given eq. is-
Figure 2.c.1- Block diagram for the given differential equation
Here, u0(t) stands for unit step function.
From above figure it is clear that we need 2 integraters, 1 adder, and 3 gain blocks.
The resultant simulink model is-
81
Simulink model-
Output:
The output waveform for vc is-
82
EXPERIMENT 2.d
OBJECTIVE - To study Sigma-Delta A/D Conversion
THEORY-
Sigma-delta modulation has recently become the method of choice for high-resolution
A/D conversion. The benefits of oversampled noise-shaping converters include inherent
linearity, reduced anti-aliasing filter complexity, high tolerance to circuit imperfection.
The process of converting an analog signal into a finite range number system
(quantization) introduces an error signal that depends on how the signal is being
approximated. This quantization error is on the order of one least-significant-bit (LSB) in
amplitude, and it is
quite small compared to full-amplitude signals. However, as the input signal gets smaller,
the quantization error becomes a larger portion of the total signal. The arrangement
shown in Figure below is called a Sigma-Delta (S-D) Modulator.
83
Figure 2.d.1- Sigma-Delta A/D Conversion
The name Sigma-Delta modulator comes from putting the integrator (sigma) in front of
the delta modulator. Delta modulation is based on quantizing the change in the signal
from sample to sample rather than the absolute value of the signal at each sample. Delta
modulation is based on quantizing the change in the signal from sample to sample rather
than the absolute value of the signal at each sample. The 1-bit digital output from the
modulator is supplied to a digital decimation filter which yields a more accurate
representation of the input signal.
The output of the sigma-delta modulator is a 1-bit data stream at the sampling
rate, which can be in the megahertz range. The purpose of the digital-and-decimation
filter is to extract information from this data stream and reduce the data rate to a more
useful value. In a sigma-delta ADC, the digital filter averages the 1-bit data stream,
improves the ADC resolution, and removes quantization noise that is outside the band of
interest. It determines the signal bandwidth, settling time, and stopband rejection.
Our Sigma-Delta A/D Converter approximation loop runs at 512 kHz. Decimation
by 64 yields final 8 kHz A/D rate. the analog input is prefiltered by an antialiasing
prefilter whose structure is simplified because of oversampling. The input signal is
oversampled by a factor of 64. The Integrator, 1-Bit Quantizer, and Zero-Order Hold
blocks comprise a two-level analog to digital converter (ADC). The output of the Zero-
Order Hold is then subtracted from the analog input. The feedback, or approximation,
84
loop causes the quantization noise generated by the ADC to be highpass filtered, pushing
its energy towards the higher frequencies (64*fs/2) and away from the relevant signal
band. The decimation stage reduces the sampling rate back to 8 KHz. During this
process, it removes the high frequency quantization noise that was introduced by the
feedback loop and removes any undesired frequency components beyond fs/2 (4 KHz)
that were not removed by the simple analog prefilter. Each decimator stage reduces the
sampling rate by a factor of four. In figure, above is analog input, and below is the
discrete digitalized output.
Simulink model-
Output Waveforms-
85
Unit -2
Sample Viva Questions
Q.1 Describe MATLAB and its applications.
Q.2 What are desktop tools available in MATLAB.
Q.3 What is the function of command window, and workspace.
Q.4 Why are the function of commands clc, clear all, close all.
Q.5 What is difference between ‘plot’ and ‘stem’ command.
Q.6 What is the function of subplot command.
86
Q.7 What is a MATLAB Toolbox.
Q.8 Define SIMULINK. What are SIMULINK Libraries.
Q.9 Define SIMULINK Blockset.
Q.10 What is the function of a ‘scope’ in ‘SIMULINK’.
Q.11How we can a sub-system in SIMULINK.
Q.12 Define BPSK modulation.
Q.13Describe briefly BPSK transmitter and receiver.
Q.14 What is a direct form I and direct form II representation of an LTI system.
Q.15 Define second order, non-homogenous differential equation.
Q.16 What is a delta modulation?
Q.17What are the basic steps in A/D conversion?
Q.18 Define a sigma-delta A/D converter?
References:-
1. Getting started with MATLAB 7
-By Rudra Pratap
2. Digital signal processing
- By S Salivahanan
A Vallavaraj
C Gyanapriya
3. Digital signal processing
-By B.P.Lathi
87
4. Analog & digital communication
-By Sanjay Sharma
Web references:-
www.mathworks.com
www.matlab.com
www.dsplaboratory.com
www.matrixlab.com
DSP Lab using TMS320C6XXX DSP Kits
Experiment 3.a
OBJECTIVE : To study the basic introduction of architecture of TMS320C6XXX DSP
kits using Bloom with DSP.
INTRODUCTION TO DSP PROCESSORS
A signal can be defined as a function that conveys information, generally about
the state or behavior of a physical system. There are two basic types of signals viz
88
Analog (continuous time signals which are defined along a continuum of times) and
Digital (discrete-time).
Remarkably, under reasonable constraints, a continuous time signal can be adequately
represented by samples, obtaining discrete time signals. Thus digital signal processing is
an ideal choice for anyone who needs the performance advantage of digital manipulation
along with today’s analog reality. digital processing must offer some clear advantages
that include:
Programmability: A single piece of digital DSP hardware can perform many functions.
For example, a multimedia PC can play music and also function as a word processor if it
is loaded with suitable programs. This ability to use the same hardware for many
functions provides important flexibility.
Stability: The stability of analog circuits depends upon several factors. Analog circuits
are affected by temperature and aging, and tolerence. Also, two analog systems using the
same design and components may differ in performance.
Repeatability: A properly designed digital circuit will produce the same result every
time, in addition to being identicalfrom unit to unit. If the same multiplication is
performed on 500 computers, all 500 computers shouldproduce the same result.
Component tolerances, aging, and temperature drifts also do not affect digital circuits
nearly as much.
Temperature: Digital circuits do not gradually change their characteristics over time,
temperature, or humidity. Theyeither work or they don’t work. In other words, digital
circuits are repeatable as long as they are designed with enough tolerance to operate
properly over the range of expected conditions.
Aging: The effects of component aging can be detrimental to analog circuits as
characteristics and performancechange. These effects can sometimes be anticipated, or
their effect may not be critical. Analog designers must be aware of these effects.
Some practical applications of DSP systems are: Toys, Videophones, Modems,
Phone Systems, 3D Graphics, Image Processing.
Components of a Typical DSP System
89
Typical DSP systems consist of a DSP chip, memory, possibly an analog-to-digital
converter (ADC), digital-to-analog converter (DAC), and communication channels.
DSP Chip
A DSP chip can contain many hardware elements; some of the more common ones are
listed below.
Central Arithmetic Unit
This part of the DSP performs major arithmetic functions such as multiplication and
addition. It is the part that makes the DSP so fast in comparison with traditional
processors.
Auxiliary Arithmetic Unit
DSPs frequently have an auxiliary arithmetic unit that performs pointer arithmetic,
mathematical calculations, or logical operations in parallel with the main arithmetic unit.
Serial Ports
DSPs normally have internal serial ports for high-speed communication with other DSPs
and data converters. These serial ports are directly connected to the internal buses to
improve performance, to reduce external address decoding problems, and to reduce cost.
Memory
Memory holds information, data, and instructions for DSPs and is an essential part of any
DSP system. Although DSPs are intelligent machines, they still need to be told what to
do. Memory devices hold a series of instructions that tell the DSP which operations to
perform on the data (i.e., information).
A/D and D/A Converters
Analog-to-digital converters (ADCs) accept analog input and turn it into digital data that
consist of only 0s and 1s. Digital-to-analog converters (DACs) perform the reverse
process; they accept digital data and convert it to a continuous analog signal.
Ports
90
Communication ports are necessary for a DSP system. Raw information is received and
processed; then that information is transmitted to the outside world through these ports.
For example, a DSP system could output information to a printer through a port. The
most common ports are serial and parallel ports. A serial port accepts a serial (single)
stream of data and converts it to the processor format. When the processor wishes to
output serial data, the port accepts processor data and converts it to a serial stream (e.g.,
modem connectionson PCs). A parallel port does the same job, except the output and
input are in parallel (simultaneous) format. The most common example of a parallel port
is a printer port on a PC.
Hence a processor which is designed to perform the special operations (digital
manipulations) on the digital signal within very less time can be called as a Digital signal
processor. The difference between a DSP processor, conventional microprocessor and a
microcontroller are listed below.
Microprocessor or General Purpose Processor such as Intel xx86 or Motorola 680xx
family
Contains - only CPU
-No RAM
-No ROM
-No I/O ports
-No Timer
Microcontroller such as 8051 family
Contains - CPU
- RAM
- ROM
-I/O ports
- Timer &
- Interrupt circuitry
91
Some Micro Controllers also contain A/D, D/A and Flash Memory
DSP Processors such as Texas instruments and Analog Devices
Contains - CPU
- RAM
-ROM
- I/O ports
- Timer
Optimized for – fast arithmetic
- Extended precision
- Dual operand fetch
- Zero overhead loop
- Circular buffering
The basic features of a DSP Processor are:
Feature Use
Fast-Multiply accumulate Most DSP algorithms, including filtering,
transforms, etc. are multiplication- intensive
Multiple – access memory architecture Many data-intensive DSP operations require
reading a program instruction and multiple data
items during each instruction cycle for best
performance
Specialized addressing modes Efficient handling of data arrays and first-in, first-
out buffers in memory
92
Specialized program control Efficient control of loops for many iterative DSP
algorithms. Fast interrupt handling for frequent
I/O operations.
On-chip peripherals and I/O interfaces On-chip peripherals like A/D converters allow for
small low cost system designs. Similarly I/O
interfaces tailored for common peripherals allow
clean interfaces to off-chip I/O devices.
Experiment-3.b
OBJECTIVE : To study the architecture of TMS320C6XXX DSP kit.
Theory:
Computers need instructions to operate. At every clock cycle, they must be told what to
do. If the instructions are stored, the computer just has to fetch and execute them. Such
computers are called stored Program machines. Our computer typically fetches an
instruction and then data, operates on the data, and returns the resulting data to the store.
Stored program machines use two well-known and widely used computer architectures:
93
von Neuman and Harvard.. The following diagram shows the structure of the two
architectures.
von Neuman Architecture
The von Neuman machines store programming and data in the same memory area. In this
type of machine, an instruction contains the operation command and the address of the
data on which the operation is performed. There are two basic operation units within
these machines: the arithmetic logic unit (ALU) and the input/output unit. The ALU
performs the core operations: multiply, add, subtract, and many more. It is on these very
simple core operations that complex software, such as word processing software, can be
built. The input/output unit manages the flow of external data for the machine.
Harvard Architecture
The primary difference between Harvard architecture and von Neuman architecture is
that with Harvard, program and data memories are physically separated transmission
paths. This enables the machine to transfer instructions and data simultaneously. Such a
structure can greatly enhance performance, because instructions and data can be fetched
simultaneously. Harvard machines also have ALUs and input/output units.
The drawback to using a true Harvard architecture is that since it uses separate
program and data memories, it needs twice as many address and data pins on the chip and
twice as much external memory. Unfortunately, as the number of pins or chips increases,
so does the price.
Electronic designers, who have had to tackle problems like these before, have come up
with an elegant solution: a single data and address bus is used externally, while two (or
more) separate buses for program and data are used internally. Timing (multiplexing)
handles the separation of program and data information. In one clock cycle, the program
information flows on the pins, and in the second cycle, data follows on the same pins.
Program and data information is then routed onto separate internal program and data
buses. Such machines are called modified Harvard architecture processors because the
internal architecture is Harvard while the external architecture is von Neuman.
94
Figure 3.b.1- Harward and von Neuman architecture.
ARCHITECTURE OF 6713 DSP PROCESSOR
This chapter provides an overview of the architectural structure of the TMS320C67xx
DSP, which comprises the central processing unit (CPU), memory, and on-chip
peripherals. The C67xE DSPs use an advanced modified Harvard architecture that
maximizes processing power with eight buses. Separate program and data spaces allow
simultaneous access to program instructions and data, providing a high degree of
parallelism. For example, three reads and one write can be performed in a single cycle.
Instructions with parallel store and application-specific instructions fully utilize this
architecture. In addition, data can be transferred between data and program spaces. Such
Parallelism supports a powerful set of arithmetic, logic, and bit-manipulation operations
that can all be performed in a single machine cycle. Also, the C67xx DSP includes the
control mechanisms to manage interrupts, repeated operations, and function calling.
95
Figure 3.d.2- BLOCK DIAGRAM OF TMS 320VC 6713
Bus Structure
The C67xx DSP architecture is built around eight major 16-bit buses (four program/data
buses and four address buses):
96
_ the program bus (PB) carries the instruction code and immediate operands from
Program memory.
_ Three data buses interconnect to various elements, such as the CPU, data address
generation logic, program address generation logic, on-chip peripherals, and data
memory.
_ The CB and DB carry the operands that are read from data memory.
_ The EB carries the data to be written to memory.
_ Four address buses (PAB, CAB, DAB, and EAB) carry the addresses needed for
Instruction execution.
The C67xx DSP can generate up to two data-memory addresses per cycle using the two
auxiliary register arithmetic units (ARAU0 and ARAU1). The PB can carry data
operands stored in program space (for instance, a coefficient table) to the multiplier and
adder for multiply/accumulate operations or to a destination in data space for data move
instructions (MVPD and READA). This capability, in conjunction with the feature of
dual-operand read, supports the execution of single-cycle, 3-operand instructions such as
the FIRS instruction. The C67xx DSP also has an on-chip bidirectional bus for accessing
on-chip peripherals. This bus is connected to DB and EB through the bus exchanger in
the CPU interface. Accesses that use this bus can require two or more cycles for reads
and writes, depending on the peripheral’s structure.
Central Processing Unit (CPU)
The CPU is common to all C67xE devices. The C67x CPU contains:
_ 40-bit arithmetic logic unit (ALU)
_ Two 40-bit accumulators
_ Barrel shifter
_ 17 × 17-bit multiplier
_ 40-bit adder
97
_ Compare, select, and store unit (CSSU)
_ Data address generation unit
_ Program address generation unit
Arithmetic Logic Unit (ALU)
The C67x DSP performs 2s-complement arithmetic with a 40-bit arithmetic logic unit
(ALU) and two 40-bit accumulators (accumulators A and B). The ALU can also perform
Boolean operations. The ALU uses these inputs:
_ 16-bit immediate value
_ 16-bit word from data memory
_ 16-bit value in the temporary register, T
_ Two 16-bit words from data memory
_ 32-bit word from data memory
_ 40-bit word from either accumulator
The ALU can also function as two 16-bit ALUs and perform two 16-bit operations
Simultaneously.
98
Figure 2.d.3 – ALU UNIT
Accumulators
Accumulators A and B store the output from the ALU or the multiplier/adder block. They
can also provide a second input to the ALU; accumulator A can be an input to the
Multiplier/adder. Each accumulator is divided into three parts:
_ Guard bits (bits 39–32)
_ High-order word (bits 31–16)
_ Low-order word (bits 15–0)
Instructions are provided for storing the guard bits, for storing the high- and the loworder
accumulator words in data memory, and for transferring 32-bit accumulator words in or
out of data memory. Also, either of the accumulators can be used as temporary storage
for the other.
Barrel Shifter
The C67x DSP barrel shifter has a 40-bit input connected to the accumulators or to data
memory (using CB or DB), and a 40-bit output connected to the ALU or to data memory
(using EB). The barrel shifter can produce a left shift of 0 to 31 bits and a right shift of 0
to 16 bits on the input data. The shift requirements are defined in the shift count field of
the instruction, the shift count field (ASM) of status register ST1, or in temporary register
T (when it is designated as a shift count register).The barrel shifter and the exponent
encoder normalize the values in an accumulator in a single cycle. The LSBs of the output
are filled with 0s, and the MSBs can be either zero filled or sign extended, depending on
the state of the sign-extension mode bit (SXM) in ST1. Additional shift capabilities
99
enable the processor to perform numerical scaling, bit extraction, extended arithmetic,
and overflow prevention operations.
Multiplier/Adder Unit
The multiplier/adder unit performs 17 _ 17-bit 2s-complement multiplications with a 40-
bit addition in a single instruction cycle. The multiplier/adder block consists of several
elements: a multiplier, an adder, signed/unsigned input control logic, fractional control
logic, a zero detector, a rounder (2s complement), overflow/saturation logic, and a 16-bit
temporary storage register (T). The multiplier has two inputs: one input is selected from
T, a data-memory operand, or accumulator A; the other is selected from program
memory, data memory, accumulator A, or an immediate value. The fast, on-chip
multiplier allows the C54x DSP to perform operations efficiently such as convolution,
correlation, and filtering. In addition, the multiplier and ALU together execute
multiply/accumulate (MAC) computations and ALU operations in parallel in a single
instruction cycle. This function is used in determining the Euclidian distance and in
implementing symmetrical and LMS filters, which are required for complex DSP
algorithms. See section 4.5, Multiplier/Adder Unit, on page 4-19, for more details about
the multiplier/adder unit.
100
Figure 2.d.4 - MULTIPLIER/ADDER UNIT
These are the some of the important parts of the processor and you are instructed to go
through the detailed architecture once which helps you in developing the optimized code
for the required application.
PROCEDURE FOR 6713 DSK
Step: I
1. First connect the dsk 6713 kit by USB cable and power on.
2. Now some LEDs glowing on
3. Open the 6713 DSK diagnostic (driver) icon.
4. Reset the kit
101
5. Give start in driver, now it start to checks all .
6. Finally it displays PASS.
7. Then click close the window.
Step: II
1. Open the CCS setup and select Family-c67xx, platform-DSK, endianneslittle.
2. Select C67xx DSK board and add then save & quit.
3. Now CCS will open.
4. Go Debugconnect
5. ProjectNew projectgive project name Finish.
6. File NewSource file. (now editor window will open).
7. Type your C code in editor window.
8. File Save give name.C Save.
9. Project Add files to project select your C program and open it.
10. Project Save project.
11. Project Build. (now your c code converted into .out format)
12. File Load program Select your .out file Open. (.out file present in
the path where you are stored .C file)
13. Now your program is loading and disassembly will open.
14. If your program wants inputs go View Memory.
15. Give data memory location Ok (now new window will open)
16. Double click on data side new window will open give data
increment the address.
17. Open your output memory location also.
18. Debug Run debug Halt.
19. Now you will see the output in your output memory location
102
103
104
105
106
107
108
109
110
111
112
Experiment-3.c
OBJECTIVE : To perform linear convolution using DSP processor.
Procedure to create new Project:
1. To create project, Go to Project and Select New.
113
Mathematical Formula:
The linear convolution of two continuous time signals x(t) and h(t) is defined by:
For discrete time signals x(n) and h(n), is defined by:
114
Where x(n) is the input signal and h(n) is the impulse response of the system.
In linear convolution length of output sequence is,
Length (y(n)) = length(x(n)) + length(h(n)) – 1.
Program:
#include<stdio.h>
main()
{
int m=4; /*Lenght of i/p samples sequence*/
int n=4; /*Lenght of impulse response Co-efficients */
int i=0,j;
int x[10]={1,2,3,4,0,0,0,0}; /*Input Signal Samples*/
int h[10]={1,2,3,4,0,0,0,0}; /*Impulse Response Co-efficients*/
/*At the end of input sequences pad 'M' and 'N' no. of zero's*/
int *y;
y=(int *)0x0000100;
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
for(i=0;i<m+n-1;i++)
printf("%d\n",y[i]);
}
Output:
1, 4, 10, 20, 25, 24, 16.
Or
115
#include<stdio.h>
int x[15],h[15],y[15];
main ()
{
int i,j,m,n;
printf("\n enter value for m");
scanf("%d",&m);
printf("\n enter value for n");
scanf("%d",&n);
printf("Enter values for i/p x(n):\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf("Enter Values for i/p h(n) \n");
for(i=0;i<n; i++)
scanf("%d",&h[i]);
// padding of zeros
for(i=m;i<=m+n-1;i++)
x[i]=0;
for(i=n;i<=m+n-1;i++)
h[i]=0;
/* convolution operation */
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
{
y[i]=y[i]+(x[j]*h[i-j]);
}}
//displaying the o/p
for(i=0;i<m+n-1;i++)
116
printf("\n The Value of output y[%d]=%d",i,y[i]);
}
Result:
enter value for m4
enter value for n4
Enter values for i/p
1 2 3 4
Enter Values for n
1 2 3 4
The Value of output y[0]=1
The Value of output y[1]=4
The Value of output y[2]=10
The Value of output y[3]=20
The Value of output y[4]=25
The Value of output y[5]=24
The Value of output y[6]=16
117
118
119
120
121
122
123
124
125
Experiment 3.d
OBJECTIVE : To implement circular convolution of two sequences.
Theory:
Circular Convolution:
Let x1(n) and x2(n) are finite duration sequences both of length N with DFT’s X1(k) and
X2(k). Convolution of two given sequences x1(n) and x2(n) is given by the equation,
x3(n) = IDFT[X3(k)]
X3(k) = X1(k) X2(k)
Program:
#include<stdio.h>
int m,n,x[30],h[30],y[30],i,j,temp[30],k,x2[30],a[30];
void main()
{
int *y;
y=(int *)0x0000100;
printf(" enter the length of the first sequence\n");
scanf("%d",&m);
printf(" enter the length of the second sequence\n");
scanf("%d",&n);
printf(" enter the first sequence\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf(" enter the second sequence\n");
126
for(j=0;j<n;j++)
scanf("%d",&h[j]);
if(m-n!=0) /*If length of both sequences are not equal*/
{
if(m>n) /* Pad the smaller sequence with zero*/
{
for(i=n;i<m;i++)
h[i]=0;
n=m;
}
for(i=m;i<n;i++)
x[i]=0;
m=n;
}
y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++) /*folding h(n) to h(-n)*/
a[j]=h[n-j];
/*Circular convolution*/
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
for(k=1;k<n;k++)
{
y[k]=0;
/*circular shift*/
for(j=1;j<n;j++)
x2[j]=a[j-1];
x2[0]=a[n-1];
for(i=0;i<n;i++)
{
127
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
/*displaying the result*/
printf(" the circular convolution is\n");
for(i=0;i<n;i++)
printf("%d ",y[i]);
}
Or
/* program to implement circular convolution */
#include<stdio.h>
int m,n,x[30],h[30],y[30],i,j, k,x2[30],a[30];
void main()
{
printf(" Enter the length of the first sequence\n");
scanf("%d",&m);
printf(" Enter the length of the second sequence\n");
scanf("%d",&n);
printf(" Enter the first sequence\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf(" Enter the second sequence\n");
for(j=0;j<n;j++)
scanf("%d",&h[j]);
if(m-n!=0) /*If length of both sequences are not equal*/
{
if(m>n) /* Pad the smaller sequence with zero*/
{
for(i=n;i<m;i++)
128
h[i]=0;
n=m;
}
for(i=m;i<n;i++)
x[i]=0;
m=n;
}
y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++) /*folding h(n) to h(-n)*/
a[j]=h[n-j];
/*Circular convolution*/
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
for(k=1;k<n;k++)
{
y[k]=0;
/*circular shift*/
for(j=1;j<n;j++)
x2[j]=a[j-1];
x2[0]=a[n-1];
for(i=0;i<n;i++)
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
/*displaying the result*/
printf(" The circular convolution is\n");
for(i=0;i<n;i++)
printf("%d \t",y[i]);
129
}
Output:
enter the length of the first sequence
4
enter the length of the second sequence
4
enter the first sequence
4 3 2 1
enter the second sequence
1 1 1 1
the circular convolution is
10 10 10 10
Procedure to create new Project:
1. To create project, go to Project and Select New.
130
131
132
133
134
135
136
137
138
139
140
Experiment 3.e
OBJECTIVE : To compute N-Point DFT of a given sequence using DSP Processor.
Theory:
Discrete Fourier Transform: The Discrete Fourier Transform is a powerful
computation tool which allows us to evaluate the Fourier Transform X(ejω) on a digital
computer or specially designed digital hardware. Since X(ejω) is continuous and
periodic, the DFT is obtained by sampling one period of the Fourier Transform at a finite
number of frequency points. Apart from determining the frequency content of a signal,
DFT is used to perform linear filtering operations in the frequency domain. The sequence
of N complex numbers x0,..., xN−1 is transformed into the sequence of N complex
numbers X0, ..., XN−1 by the DFT according to the formula:
Program:
//DFT of N-point from lookup table. Output from watch window
#include <stdio.h>
#include <math.h>
#define N 4 //number of data values
float pi = 3.1416;
short x[N] = {1,1,0,0}; //1-cycle cosine
float out[2] = {0,0}; //initialize Re and Im results
void dft(short *x, short k, float *out) //DFT function
{
float sumRe = 0; //initialize real component
float sumIm = 0; //initialize imaginary component
int i = 0;
141
float cs = 0; //initialize cosine component
float sn = 0; //initialize sine component
for (i = 0; i < N; i++) //for N-point DFT
{ cs =
cos(2*pi*(k)*i/N); //real component
sn = sin(2*pi*(k)*i/N); //imaginary component
sumRe = sumRe + x[i]*cs; //sum of real components
sumIm = sumIm - x[i]*sn; //sum of imaginary components
}
out[0] = sumRe; //sum of real components
out[1] = sumIm; //sum of imaginary components
87
printf("%f %f\n",out[0],out[1]);
}
void main()
{ int j;
for (j = 0; j < N; j++)
dft(x, j, out); //call DFT function
}
Output:
2.000000 0.000000
0.999996 -1.000000
0.000000 0.000007
1.000011 1.000000
142
Procedure to create new Project:
1. To create project, Go to Project and Select New.
143
144
145
146
147
148
149
150
151
152
153
Experiment 3.f
OBJECTIVE : To find Impulse response of a first order and second order LTI system.
Theory:
A discrete time system performs an operation on an input signal based on predefined
criteria to produce a modified output signal. The input signal x(n) is the system
excitation, and y(n) is the system response. The transform operation is shown as,
Figure 3.f.1- Transform operation.
If the input to the system is unit impulse i.e. x(n) = δ(n) then the output of the system is
known as impulse response denoted by h(n) where,
h(n) = T[δ(n)]
Any arbitrary sequence x(n) can be represented as a weighted sum of discrete impulses.
Now the system response for a linear system is given by-
y(n) = Σx(k) T[δ(n-k)]
for k = - to .
The response to the shifted impulse sequence can be denoted by-
h(n- k) = T[δ(n-k)]
that implies that,
y(n) = Σx(k) h(n-k)
154
for k= - to .
That implies that for a linear time-invariant system if the input sequence is x(n) and
impulse response h(n) is given, we can fine output y(n) by using above equation, which is
known as convolution sum(discussed later) and can be represented by y(n) = x(n) * h(n).
The general form of difference equation is,
Impulse response of second order difference equation:
Program:
#include<stdio.h>
#define Order 2
#define Len 5
float h[Len] = {0.0,0.0,0.0,0.0,0.0},sum;
void main()
{
int j, k;
float a[Order+1] = {0.1311, 0.2622, 0.1311};
float b[Order+1] = {1, -0.7478, 0.2722};
for(j=0; j<Len; j++)
{
sum = 0.0;
for(k=1; k<=Order; k++)
{
155
if ((j-k) >= 0)
sum = sum+(b[k]*h[j-k]);
}
if (j<= Order)
h[j] = a[j]-sum;
else
h[j] = -sum;
printf (" %f ",h[j]);
}
}
Output:
0.131100 0.360237 0.364799 0.174741 0.031373
For first order difference equation.
Program:
#include<stdio.h>
#define Order 1
#define Len 5
float h[Len] = {0.0,0.0,0.0,0.0,0.0},sum;
void main()
{
int j, k;
float a[Order+1] = {0.1311, 0.2622};
float b[Order+1] = {1, -0.7478};
for(j=0; j<Len; j++)
{
sum = 0.0;
for(k=1; k<=Order; k++)
156
{
if((j-k)>=0)
sum = sum+(b[k]*h[j-k]);
}
if(j<=Order)
h[j] = a[j]-sum;
else
h[j] = -sum;
printf("%f ", j, h[j]);
}
}
Output:
0.131100 0.360237 0.269385 0.201446 0.150641
Procedure to create new Project:
1. To create project, Go to Project and Select New.
157
158
159
4. Enter the source code and save the file with “ .C” extension.
160
5. Right click on source, Select add files to project .. and Choose “.C “ file Saved before.
161
6. Right Click on libraries and select add files to Project.. and choose C:\CCStudio_v3.1\
C6000\cgtools\lib\rts6700.lib and click open.
162
7. a) Go to Project to Compile.
b) Go to Project to Build.
163
c) Go to Project to Rebuild All.
8. Go to file and load program and load “.out” file into the board.
164
9. Go to Debug and click on run to run the program.
165
166
10. Observe the output in output window.
167
168
169
Unit -3
Sample Viva Questions
Q.1 Define digital data, and a DSP processor.
Q.2 Specify some practical applications of DSP systems.
Q.3 What are the advantages of digital systems over the analog systems?
Q.4 What is the difference between microprocessor, microcontroller, and a DSP
processor.
Q.5 Explain the Components of a Typical DSP System.
Q.6 What are the two basic architectures used in DSP processor.
Q.7 Explain Von Neuman architecture.
Q.8 Explain Harward architecture.
Q.9What is the difference between Von Neuman and Harward architecture.
Q.10 What is modified Harvard architecture.
Q.11 Specify additional features in a DSP processor, making it superior from
microprocessor/ microcontroller.
Q.12 Explain bus structure in C67xx processor.
Q.13 Explain the function of data buses and address bus.
Q.14 Specify any four features of CPU in C67xx processor.
Q.15 Explain the Arithmetic Logic Unit (ALU) in C67x DSP.
Q.16 Define data storage in accumulator.
Q.17 What is the functionality of a barrel shifter.
Q.18 Explain MAC(Multiply add accumulate).
Q.19 What is the advantage of using a MAC.
170
Beyond Syllabus
EXPERIMENT NO-4
OBJECTIVE: Implementation of Transfer function of Log Gabor Filters.
THEORY:
A Gabor filter, named after Dennis Gabor, is a linear filter used for edge detection in
images. In the spatial domain, a 2D Gabor filter is a 2D Gaussian function modulated by
a sinusoidal plane wave. Means, a Gaussian function is multiplied to a sinusoidal wave.
A generalized equation for Gabor function in 2D form is-
Gabor filters are a traditional choice for obtaining localized frequency information. These
are filters having a Gaussian transfer function when viewed on the linear frequency scale.
Bandwidth limitations of Gabor filters
The maximum bandwidth of a Gabor filter is limited to approximately one octave and
Gabor filters are not optimal if one is seeking broad spectral information. One cannot
construct Gabor functions of arbitrarily wide bandwidth and still maintain a reasonably
small DC component in the even-symmetric filter. This difficulty can be seen if we look
at the transfer function of an even-symmetric Gabor filter in the frequency domain. The
transfer function is the sum of two Gaussians centered at plus and minus the centre
frequency. If the standard deviation of these Gaussians becomes more than about one
third of the centre frequency the tails of the two Gaussians will start to overlap
excessively at the origin, resulting in a nonzero DC component, as shown in figure.1. At
171
the limiting situation where the centre frequency is equal to three standard deviations, the
bandwidth will be approximately one octave.
Figure-4.a.1- Transfer function of a high bandwidth even-symmetric Gabor
The Log-Gabor Filter
An alternative to the Gabor function is the log-Gabor function proposed by Field [1987].
Field suggests that natural images are better coded by filters that have Gaussian transfer
functions when viewed on the logarithmic frequency scale. (Gabor functions have
Gaussian transfer functions when viewed on the linear frequency scale). On the linear
frequency scale the log-Gabor function has a transfer function of the form
G(w) = e (-log(w/wo)2) / ( 2 (log(k/w
o)2 )
where wo is the filter's centre frequency. To obtain constant shape ratio filters the term
k/wo must also be held constant for varying wo. For example, a k/wo value of .74 will
result in a filter bandwidth of approximately one octave, .55 will result in two octaves,
and .41 will produce three octaves.
There are two important characteristics to note. Firstly, log-Gabor functions, by definition,
always have no DC component, and secondly, the transfer function of the log Gabor function has
an extended tail at the high frequency end.
172
Figure-4.a.2- An example of a log-Gabor transfer function viewed on both linear and
logarithmic frequency scales.
In spatial domain, their appearance is similar to Gabor functions though their shape
becomes much `sharper' as the bandwidth is increased. The shapes of log Gabor and
Gabor functions are almost identical for bandwidths less than one octave.
Applications of log-Gabor filters-
We have studied that compared with Gabor filters, Log-Gabor filters have two important
characteristics. Firstly, Log-Gabor filters, always have no DC component. Secondly, the
transfer function of the Log-Gabor filters has an extended tail at the high frequency end.
Field’s studies indicate that natural images have amplitude spectra that fall off at
approximately 1/f. To encode images having such spectral characteristics one should use
filters having the similar spectra. Field suggests that Log-Gabor filters, having extended
tails, should be able to encode natural images more efficiently than ordinary Gabor
filters, which would over-represent the low frequency components and under-represent
the high frequency components in any encoding.
Log-Gabor filters are widely used in the field of image processing like, texture
Analysis /synthesis, contour extraction , segmentation ,object recognition, image analysis
and compression , movement estimation or image restoration due to two characteristics:
- Directionality: filters can be rotated to discriminate spectral features in multiple
173
directions.
- Complex modulation (odd/even phases): effective for analyzing different
phasedfeatures like abrupt ridges or edges.
174
Sample Viva Questions
Q.1 Define a filter.
Q.2 What is a transfer function of a filter?
Q.3 Classify filters according to the range of frequencies it pass. Also specify their
transfer functions.
Q.4 What do you mean log frequency scale?
Q.5 How does the log frequency scale differ from linear frequency scale?
Q.6 What is a 2-D Gabor filter? State its transfer function.
Q.7 What is the bandwidth limitation of a Gabor filter.
Q.8 State transfer function of a log Gabor filter .
Q.9 State two important characteristics of transfer function of log Gabor filter.
Q.10 How do you differentiate a log Gabor filter from a Gabor filter?
Q.11 What are the advantages of Gabor filter over log Gabor filter?
Q.12 What is the range of bandwidth for which log Gabor filter and Gabor filter have
same characteristics.
Q.13 What property of log Gabor filter transfer function make them suitable to encode
natural images?
Q.14 What do you mean by directionality of log Gabor filter.
Q.15 State some applications of log Gabor filter?
175
EXPERIMENT NO-5
OBJECTIVE: Removal of noise from image signals using various spatial filtering
operations.
Theory:
Here we will study about the concept of an image, various noise signals contaminating
the image, and spatial filtering techniques to remove that noise.
Concept of image
An image may be defined as a two-dimensional function,f(x, y), where x and y are spatial
(plane) coordinates, also called as a pixel, and the amplitude of f at any pair of
coordinates (x, y) is called the intensity or gray level of the image at that point(pixel).
When x, y and the amplitude values of f are all finite, discrete quantities, we call the
image a digital image.
Thus, a rectangular black-and-white image is a matrix where each entry represents
an intensity of gray at that spot and ranges from 0 to 255, 0 being the darkest spot and
255 being the brightest spot.
Noise in images
In practice, an image may be degraded by various types and forms of noise. However, the
most common type of noise is the additive one. The principal source of noise in digital
images arise during image acquisition (digitization) or transmission. The performance of
imaging sensors is affected by a variety of factors, such as the environmental conditions
during image acquisition, and by the quality of the sensing elements themselves. Various
additive noises in image are Gaussian noise, Uniform noise,and Impulse (salt-and-
pepper) noise. Each noise component of the model may be considered random variables,
characterized by its specific probability density function (PDF). Two most common
occurring additive noises, Impulse and Gaussian noise are shown in fig.-3.
176
Figure-4.b.1- PDF of (a)Gaussian noise (b)Impulse(Salt and Pepper noise)
MATLAB command for adding noise -
Here we discuss important command in MATLAB which are used to add noise to image
signals.
Imnoise-
This command adds noise to an image. Its syntax for above discussed noises are-
J = imnoise (I ,' gaussian' ,m ,v)
J = imnoise (I, 'salt & pepper', d)
Where-
J = Noisy image;
I = Input image;
'gaussian' = Gaussian white noise with constant mean and variance. The default is zero
mean noise with 0.01 variance.;
m, v = mean (m) and variance (v) to the image I.
'salt & pepper' = On and off pixels.
177
d = d is the noise density. The default for d is 0.05.
Filtering methods to remove noise-
Spatial filtering is the method of choice in situations when only additive noise is present.
Some neighborhood operations work with the values of the image pixels in the
neighborhood and the corresponding values of a sub-image that has the same dimensions
as the neighborhood. The sub-image is called a filter, or window.
The mechanics of spatial filtering consists simply of moving the filter window from
point to point in an image. At each point (x, y), the response ofthe filter at that point is
calculated using a predefined relationship.
In this section we see some noise reduction spatial filters. Let us assume noisy
image as g . S represent the set of coordinates in a rectangular sub image window of size
m x n, centered at point (x, y) . f represent the denoised image.
Linear(Mean) filtering
A mean filter acts on an image by smoothing it; that is, it reduces the intensity variation
between adjacent pixels. It is preferable for impulse noise. The mean filter is nothing but
a simple sliding window spatial filter that replaces the center value in the window with
the average of all the neighboring pixel values including itself. It is implemented with a
convolution mask, which provides a result that is a weighted sum of the values of a pixel
and its neighbors. It is also called a mean filter. The mask or kernel is a square.
Linear filter is of three types-
1). Arithmetic mean filter- The arithmetic mean filtering process computes the average
value of the corrupted image g(x, y) in the area defined by S .The value of the denoised
image f at any point (x, y) is simply the arithmetic mean computed using the pixels in the
region defined by S.
2). Geometric mean filter- An image denoised using a geometric mean filter is given by
each denoised pixel is the geometric mean of the pixels in the subimage window.
3). Harmonic mean filter- An image denoised using a harmonicic mean filter is given
by each denoised pixel is the harmonic mean of the pixels in the subimage window.
178
Median filter
The median filter calculates median of the pixel values in the window is computed, and
the center pixel of the window is replaced with the computed median. Thus , Median
filter, replaces the value of a pixel by the median of the gray levels in the neighborhood
of that pixel.
Median filtering is done by, first sorting all the pixel values from the surrounding
neighborhood into numerical order and then replacing the pixel being considered with the
middle pixel value.
Adaptive Filtering
The fundamental difference between the mean filter and the adaptive filter lies in the fact
that the filter mask varies after each iteration in the adaptive filter. Adaptive filters are
capable of denoising images that have abrupt changes in intensity. Mean and variance are
the parameters on which to base an adaptive filler because they are quantities closely
related to the appearance of an image.
179
Sample Viva Questions
Q.1 How we represent an image mathematically in image processing?
Q.2 What is a pixel?
Q.3 Define grey level of a pixel?
Q.4 What are the principal source of noise in digital images?
Q.5 What is an additive noise?
Q.6 State any three additive noise. How are they characterized or differ?
Q.7 Which MATLAB command is used to add noise in image? Give its syntax.
Q.8 What is mean and variance of noise in an image?
Q.9 Define spatial filtering?
Q.10 What is the function of window in spatial filtering?
Q.11 Define linear filtering.
Q.12 What are the various types of linear filtering? Define each.
Q.13 Define median filtering. How it differ from adaptive filtering?
Q.14 Give an example of adaptive filtering?
Q.15 What is multiplicative noise? How it differ from additive noise?
180
EXPERIMENT NO-6
OBJECTIVE: Write a program in MATLAB to Remove noise from an image signal
using various spatial filtering operations.
OBJECTIVE - Removal of noise from an image signal using various spatial filtering operations.
Program-
1. clc;
2. clear all;
3. close all;
4. I = imread('cameraman.tif');
5. figure(1),imshow(I);
6. J = imnoise(I,'salt & pepper',0.04);
7. figure(2),imshow(J);
8. K = filter2(fspecial('average',3),J)/255;
9. figure(3),imshow(K);
10. L = medfilt2(J,[3 3]);
11. figure(4), imshow(L);
12. M = imnoise(I,'gaussian',0,0.01);
13. figure(5),imshow(M);
14. N = wiener2(J,[5 5]);
15. figure(6),imshow(N);
181
Output-
182
183
Sample Viva Questions
Q.1What is the function of clc, clear all, close all commands in MATLAB?
Q.2 What is the command for reading an image in MATLAB?
Q.3 What is the command for displaying an image in MATLAB?
Q.4 What is the command for adding noise in image?
Q.5Which are the noises added in above program in an image? Also give syntax to add
these noises to image.
Q.6 What is the function of command ‘fspecial’?
Q.7 Write syntax for applying mean(average) filter on an image in MATLAB?
Q.8 What is the command for applying a median filter on a noisy image?
Q.9 What do you mean by ‘mean’ and ‘variance’ of Gaussian noise?
Q.10 What do you mean by standard deviation of ‘Impulse noise’?
Q.11 Why do we call an Impulse noise, a ‘salt and pepper’ noise?
Q12 What is the standard size of mean and median filter we are applying on image?
Q.13What is the basic difference between mean and median filter?
Q.14 Which type of filter, the Weiner filter is?
Q.15What basic operation does the Weiner filter apply on image?
184
EXPERIMENT NO-7
OBJECTIVE: To study Wavelets, wavelet transform and wavelet decomposition.
Theory:
Need of Wavelet Transform
Fourier Transforms gives the us spectral/frequency content of the signal, but it
gives no information regarding where in time those spectral components appear.
Therefore, Fourier Transforms are not suitable technique for non-stationary signals.
Signals whose frequency content change in time are called non-stationary signals. Means
all frequency contents does not exist all the time, or the existing frequency changes
linearly in time. Ex – chirp signal.
Thus, the Fourier Transform gives what frequency components (spectral
components) exist in the signal. Nothing more, nothing less.
Introduction to wavelet transform-
The term wavelet means a small wave . The smallness refers to the condition that this
(window) function is of finite length (compactly supported). The wave refers to the
condition that this function is oscillatory. A wavelet is a waveform of effectively limited
duration that has an average value of zero. These wavelets form the basis functions for
wavelet transform. Compare wavelets with sine waves, which are the basis of Fourier
analysis. Sinusoids do not have limited duration — they extend from minus to plus
Infinity.
Fourier analysis consists of breaking up a signal into sine waves of various
frequencies. Similarly, wavelet analysis is the breaking up of a signal into
185
shifted and scaled versions of the original (or mother) wavelet. Signals with sharp
changes in frequencies might be better analyzed with an irregular wavelet than with a
smooth sinusoid.
Continuous Wavelet Transform
The continuous wavelet transform is defined as follows-
In the CWT, the analyzing function is a wavelet, ψ. The CWT compares the
signal to shifted and compressed or stretched versions of a wavelet. Stretching
or compressing a function is collectively referred to as dilation or scaling. By
continuously varying the values of the scale parameter, tau, and the position
parameter, s , you obtain the cwt coefficients CWT(tau, s).
x(t) is the signal to be analyzed. For convenience, the procedure will be started
from scale s=1 and will continue for the increasing values of s , i.e., the analysis will start
from high frequencies and proceed towards low frequencies. This first value of s will
correspond to the most compressed wavelet. As the value of s is increased, the wavelet
will dilate.
The wavelet is placed at the beginning of the signal at the point which corresponds
to time=0. The wavelet function at scale ``1'' is multiplied by the signal and then
integrated over all times. The result of the integration is then multiplied by the constant
number 1/sqrt{s} . This multiplication is for energy
normalization purposes so that the transformed signal will have the same energy at every
scale. The wavelet at scale s=1 is then shifted towards the right by tau amount to the
location tau , and the above equation is computed to get the transform value at tau, s=1
in the time-frequency plane.
186
This procedure is repeated until the wavelet reaches the end of the signal. The above
procedure is repeated for every value of s. When the process is completed for all desired
values of s, the CWT of the signal has been calculated.
The Discrete Wavelet Transform
Basic scaling function in Discrete Wavelet Transform are given by -
Basic scaling function in Discrete Wavelet Transform are given by-
Where, j,k are scaling and translation indices.
If the function being expanded is a sequence of numbers, like a discrete function f(x),
the resulting coefficients are called the discrete wavelet transform (DWT) of f(x). The
DWT transform pair is given by-
187
Here, f(x) , , are functions of the discrete variable x = 0, 1,2,..., M -1. The
coefficients defined as , are usually called approximation and detail
coefficients, respectively, This is because the first sum in above equation uses scaling
functions to provide an approximation of f(x) at scale j0. For each higher scale > j0 in
the second sum, a finer resolution function—a sum of wavelets—is added to the
approximation to provide increasing detail.
Normally, we let = 0 and select M to be a power of 2 (i.e., M = ) .
As, we have seen, Wavelet Transform decomposes a signal into approximation and
detail coefficients. The approximations are the high-scale, low-frequency components of
the signal. The details are the low-scale, high-frequency components. The filtering
process, at its most basic level, looks like Figure 4.
Figure 4.d.1- Wavelet Transform decomposition of a signal
188
The original signal, S, passes through two complementary filters and emerges as two
signals.
If we actually perform this operation on a real digital signal, we wind up with twice
as much data as we started with. Suppose, for instance, that the original signal S consists
of 1000 samples of data. Then the resulting signals will each have 1000 samples, for a
total of 2000. So, to reduce its size we down sample the both resulting low passed and
high passed filtered signal, to reduce its length to half.
For many signals, the low-frequency content is the most important part. It is the
average of original signal. The high-frequency content, on the other hand, imparts finer
details of the signal, like glitches, and high frequency components.
The decomposition process can be iterated, with successive approximations
Being decomposed in turn, so that one signal is broken down into many lower
Resolution components. This is called the wavelet decomposition tree. Looking at a
signal’s wavelet decomposition tree can yield valuable information. Since the analysis
process is iterative, in theory it can be continued indefinitely. Figure- 5 showes the
wavelet decomposition process, and decomposition tree for a signal.
189
Figure 4.d.2-Wavelet decomposition process, and decomposition tree for a signal.
Sample Viva Questions
Q.1 Define wavelet.
Q.2 State any three wavelets.
Q.3 What is a transform?
Q.4Why we transform a signal into other domain?
Q.5 What are basis function for Fourier and wavelet transforms?
Q.6 What is the basic difference between wavelet and fourier transform?
Q.7 What is the advantage of using Wavelet transform, over Fourier Transform?
Q.8 Explain continuous wavelet transform with the equation.
Q.9 What do you mean by scale and transition in wavelet transform?
Q.10 What are scaling function and wavelet functions?
Q.11 What are the parameters used in scaling and wavelet functions for scaling and n
translation?
Q.12 What do you mean by wavelet decomposition?
190
Q.13 What are the levels of wavelet decomposition?
Q.14 In context to the image, what do approximation and detail coefficients represent ?
Q.15 State any two applications of wavelet decomposition in image processing.
EXPERIMENT NO-4.e
OBJECTIVE: Write a program in MATLAB to decompose an image signal using
Discrete Wavelet Transform.
1. clear all;
2. clc;
3. f = imread('cameraman.tif');
4. F = im2double(f);
5. [C,S] = wavedec2(F,1,'haar');
6. A = appcoef2(C,S,'haar',1);
7. D1 = detcoef2('h', C,S,1);
8. D2 = detcoef2('v', C,S,1);
9. D3 = detcoef2('d', C,S,1);
10. c = cell(2);
11. c{1,1} = A;
12. c{1,2} = D1;
13. c{2,1} = D2;
14. c{2,2} = D3;
191
15. c = cell2mat(c);
16. c1 = im2uint8(c);
17. imshow(c1);
Output-
192
Sample Viva Questions
Q.1 Write the MATLAB command for wavelet decomposition with syntax.
Q.2 What effect does the level of decomposition causes on output?
Q.3 What are C, S matrix called? Also describe them in brief?
Q.4 Write the command to read an image in MATLAB.
Q.5 Specify different data-types in MATLAB.
Q.6 What do you understand by data type uint8?
Q.7 What do you understand by data type double?
Q.8 In which data type the image is saved in MATLAB?
Q.9 In which data type we need to change image to process it?
Q.10 What is the command for the conversion of image? Give syntax.
Q.11What change will the conversion cause in image variable?
193
Q.12 State any two types of wavelets used in image decomposition?
Q.13 What are approximate and detail coefficients.
Q.14 What are commands to generate approximate and detail coefficients
Q.15 What are cells? What is the command to convert cell data to matrix data.
References:
1. Gonzales R.C., Woods R.E. Digital Image Processing, (2ndedition). Prentice Hall
Publication.
2http://www.mathworks.com/access/helpdesk/help/pdf_doc/wavelet/wavelet_ug.pdf.
3.http://www.mathworks.com/access/helpdesk/help/pdf_doc/images/images_tb.pdf
4.www.csse.uwa.edu.au/~pk/research/matlabfns/.../convexpl.html
194