DSP Lab Manual - Updated
DSP Lab Manual - Updated
DSP Lab Manual - Updated
of ECE
TABLE OF CONTENTS
NAME OF THE EXPERIMENT PAGE
S.NO.
PART-1( SIGNALS ) NO
1 Generation of discrete time signals for discrete signals
To verify Linear Convolution
2 a) Using MATLAB
b) Using Code Composer Studio(CCS)
To verify Circular Convolution for discrete signals
3 a) Using MATLAB
b) Using Code Composer Studio(CCS)
4 To find the addition of sinusoidal signals
To verify Discrete Fourier Transform(DFT) and Inverse Discrete Fourier
Transform(IDFT)
5
a) Using MATLAB
b) Using Code Composer Studio(CCS)
Transfer Function Stability Analysis: using pole-zero plot, bode plot,
6
Nyquist plot, z-plane plot.
PART-2 ( FILTERS )
7 Frequency Response of IIR low pass Butterworth Filter
8 Frequency Response of IIR high pass Butterworth Filter
9 Frequency Response of IIR low pass Chebyshev Filter
10 Frequency Response of IIR high pass Chebyshev Filter
11 Frequency Response of FIR low pass Filter using Rectangle Window
12 Frequency Response of FIR low pass Filter using Triangle Window
PART – 3( IMAGE PROCESSING )
13 An image processing in a false contouring system
14 To generate the histogram equalization to the image
To verify the Normalized Cross Correlation to the addition of noise and
15
removal of noise using filters to an image
16 Compute the edge of an image using spatial filters.
Perform the image motion blur and calculate PSNR to the noise image and
17
also noise free image.
To verify the PSNR to the Second order Decomposition of Discrete
18 Wavelet transforms and to the reconstructed image using inverse Discrete
Wavelet transform
1
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
TOOLS REQUIRED:
TMS 320 C6713 Kit,
Code Composer Studio Software,
Personal Computer
BLOCK DIAGRAM
2
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
DESCRIPTION:
The C6713 Digital Signal Processor (DSP) Starter Kit (DSK) builds on Texas Instruments
(TI's) industry-leading line of low cost, easy-to-use DSK development boards. The high-
performance board features the TMS320C6713 floating-point DSP. Capable of performing
1350 Million Floating-point Operations per Second (MFLOPS), the C6713 DSP makes the
C6713 DSK the most powerful DSK development board. The DSK is USB port interfaced
platform that allows efficiently developing and testing applications for the C6713. The DSK
consists of a C6713-based printed circuit board that will serve as a hardware reference design
for TI’s customers’ products. With extensive host PC and target DSP software support,
including bundled TI tools, the DSK provides ease-of-use and capabilities that are attractive
to DSP engineers.
The C6713 DSK has a TMS320C6713 DSP onboard that allows full-speed verification of
code with Code Composer Studio. The C6713 DSK provides:
A USB Interface
SDRAM and ROM
An analog interface circuit for Data conversion (AIC)
An I/O port
Embedded JTAG emulation support
The C6711 DSK includes a stereo codec. This analog interface circuit (AIC) has the
following characteristics:
1. High-Performance Stereo Codec
90-dB SNR Multibit Sigma-Delta ADC (A-weighted at 48 kHz)
100-dB SNR Multibit Sigma-Delta DAC (A-weighted at 48 kHz)
1.42 V – 3.6 V Core Digital Supply: Compatible With TI C54x DSP Core
Voltages
2.7 V – 3.6 V Buffer and Analog Supply: Compatible Both TI C54x DSP
Buffer Voltages
8-kHz – 96-kHz Sampling-Frequency Support
3
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
4
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Code Composer communicates with the DSK through an embedded JTAG emulator with a
USB host interface. The DSK can also be used with an external emulator through the
external JTAG connector.
5
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
7
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
1. Click on the Code Composer Studio. And create the project of your own i.e. as shown
below:
2. To create the new source file, Click on File-> NEW-> Source file
8
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
3. Write the program in edit window and save the file in your project as *.C (for C
Program) or *.asm (Assembly Language Program)
9
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
10
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Mapping Between Instructions and Functional Units : The following Table shows which
instructions can be executed in which of the functional units for fixed point instructions.
11
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
12
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
13
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Mapping Between Instructions and Functional Units : The following Table shows which
instructions can be executed in which of the functional units for floating point instructions.
14
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
11. Click on Debug -> Run (see the result in the Output window.)
15
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Program:
.global _main
_main:
MVKL .S1 -5, A4
ABS .L1 A4, A4
ZERO .L1 A3
ADD .L1 A4, A4, A3
SUB .L1 A3, A4, A5
MPY .M1 A3, A4, A0
NOP 1
SUB .L2X A0, B0, B0
B B3
NOP 5
RESULT:
16
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
TOOLS REQUIRED:
MATLAB Software,
Personal Computer.
subplot(2,1,1);
stem(n,i);
xlabel('time index');
ylabel('amplitude');
title(' UNIT STEP SEQUENCE');
axis([-5 15 0 1.2]);
subplot(2,1,2);
stem(n,j);
xlabel('time index');
ylabel('amplitude');
title(' DELAYED UNIT STEP SEQUENCE');
axis([-5 15 0 1.2]);
18
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
y=m*t;
subplot(2,1,1);
plot(t,y);
xlabel('time index');
ylabel('amplitude');
title('UNIT RAMP');
subplot(2,1,2);
stem(t,y);
xlabel('time index');
ylabel('amplitude');
title('UNIT RAMP');
19
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
MODEL WAVEFORMS:
UNIT SAMPLE:
UNIT SAMPLE SEQUENCE
1
amplitude
0.5
0
-5 0 5 10 15
time index
DELAYED UNIT SAMPLE SEQUENCE
1
amplitude
0.5
0
-5 0 5 10 15
time index
UNIT STEP:
1
amplitude
0.5
0
-5 0 5 10 15
time index
DELAYED UNIT STEP SEQUENCE
1
amplitude
0.5
0
-5 0 5 10 15
time index
20
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
SINE WAVE:
SINE WAVE
1
0.5
amplitude
-0.5
-1
0 1 2 3 4 5 6 7 8 9 10
time index
SINE WAVE
1
0.5
amplitude
-0.5
-1
0 1 2 3 4 5 6 7 8 9 10
time index
RAMP SIGNAL:
UNIT RAMP
1
amplitude
0.5
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
time index
UNIT RAMP
1
amplitude
0.5
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
time index
21
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
TRIANGULAR SIGNAL:
TRIANGULAR WAVE
1
0.5
amplitude
-0.5
-1
0 1 2 3 4 5 6 7 8 9 10
time index
TRIANGULAR WAVE
1
0.5
amplitude
-0.5
-1
0 1 2 3 4 5 6 7 8 9 10
time index
RESULT:
22
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
TO VERIFY LINEAR CONVOLUTION
AIM: To write a program to compute the response of a discrete LTI system with input
sequence x(n) and impulse response h(n) by using linear convolution.
TOOLS REQUIRED:
TMS 320 C6713 Simulator/Kit,
Code Composer Studio Software,
MATLAB Software,
Personal Computer
PROCEDURE FOR CODE COMPOSER STUDIO:
1. Create a Project in Code Composer Studio.
2. Create a Source file in C language for Linear Convolution and add it to the project.
3. Add both hello.cmd & rts6700.lib files to the current project folder from the
following locations:
C:\CCStudio_v3.1\tutorial\dsk6713\hello1\hello.cmd and
C:\CCStudio_v3.1\C6000\cgtools\lib\rts6700.lib
4. Compile C file for debugging errors.
5. Build the project.
6. Load Program (.out file) into DSK from file menu.
7. Run the program from Debug menu.
8. Plot the Graph of linear convolution from View – graph menu.
#include<stdio.h>
int x[20],h[20],y[20],N1,N2,n,m;
main()
{
printf("Enter the length of input sequence x(n)\t:N1=");
scanf("%d",&N1);
printf("Enter the length of impulse response h(n)\t:N2=");
scanf("%d",&N2);
printf("Enter %d samples for input sequence x(n):\n",N1);
for(n=0;n<N1;n++)
scanf("%d",&x[n]);
printf("Enter %d samples for impulse response h(n):\n",N2);
for(n=0;n<N2;n++)
23
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
scanf("%d",&h[n]);
printf("Input sequence \nx(n)=");
for(n=0;n<N1;n++)
printf("\t%d",x[n]);
printf("\nImpulse Response \nh(n)=");
for(n=0;n<N2;n++)
printf("\t%d",h[n]);
for(n=0;n<N1+N2-1;n++)
{
y[n]=0;
for(m=0;m<=n;m++)
y[n]=y[n]+x[m]*h[n-m];
}
printf("\n Response of LT1 system is\ny(n)=");
for(n=0;n<N1+N2-1;n++)
printf("\t%d",y[n]);
}
INPUT:
Enter the length of input sequence x(n) :N1=
Enter the length of impulse response h(n):N2=
Enter 4 samples for input sequence x(n):
Enter 4 samples for impulse response h(n):
y(n) =
24
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
MODEL GRAPH:
stem(x2);
xlabel(‘n2--->’); %plot for input sequence two
ylabel(‘amplitude’);
title(‘input sequence two’);
subplot(3, 1, 3);
stem(s);
xlabel(‘n--->’); %plot for linear convolution sequence
ylabel(‘amplitude’);
title(‘linear convolution sequence ’);
MODEL GRAPH:
0
1 1.5 2 2.5 3 3.5 4
n1--->
input sequence two
4
amplitude’
0
1 1.5 2 2.5 3 3.5 4
n2--->
linear convolution sequence
40
amplitude
20
0
1 2 3 4 5 6 7
n--->
RESULT:
26
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
TO VERIFY CIRCULAR CONVOLUTION
AIM: To write a program to compute the response of a discrete LTI system with input
sequence x(n) and impulse response h(n) by using Circular convolution.
TOOLS REQUIRED:
TMS 320 C6713 Simulator/Kit,
Code Composer Studio Software,
MATLAB Software,
Personal Computer
PROCEDURE:
1. Create a Project in Code Composer Studio.
2. Create a Source file in C language for Circular Convolution and add it to the project.
3. Add both hello.cmd & rts6700.lib files to the current project folder from the
following locations:
4. C:\CCStudio_v3.1\tutorial\dsk6713\hello1\hello.cmd and
C:\CCStudio_v3.1\C6000\cgtools\lib\rts6700.lib
5. Compile C file for debugging errors.
6. Build the project.
7. Load Program (.out file) into DSK from file menu.
8. Run the program from Debug menu.
9. Plot the Graph of Circular convolution from View – graph menu.
C-PROGRAM FOR CIRCULAR CONVOLUTION:
#include<stdio.h>
int m,n,x[30],h[30],y[30],i,j,temp[30],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]);
27
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
28
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
INPUT:
Enter the length of input sequence x(n) :N1=
Enter the length of impulse response h(n):N2=
Enter 4 samples for input sequence x(n):
Enter 4 samples for impulse response h(n):
Input sequence after zero padding
x(n)=
Impulse Response after zero padding
h(n)=
MODEL GRAPH
29
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
30
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
ylabel('amplitude');
title('circular convolution sequence of x and h');
MODEL GRAPH:
first sequence
4
amplitude
0
1 1.5 2 2.5 3 3.5 4
n1---->
second sequence
2
amplitude
0
1 1.5 2 2.5 3 3.5 4
n2---->
circular convolution sequence of x and h
20
amplitude
10
0
1 1.5 2 2.5 3 3.5 4
n--->
RESULT:
31
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
clc;
clear all;
close all;
t=0:0.001:20;
x1=sin(2*pi*t/5);
subplot(3,1,1);
plot(t,x1);
xlabel('TIME INDEX');
ylabel('AMPLITUDE');
title('SUM OF SINE WAVES');
x2=sin(2*pi*t/7);
subplot(3,1,2);
plot(t,x2);
xlabel('TIME INDEX');
ylabel('AMPLITUDE');
x=x1+x2;
subplot(3,1,3);
plot(t,x);
xlabel('TIME INDEX');
ylabel('AMPLITUDE');
32
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
MODEL GRAPH:
SUM OF SINE WAVES
1
AMPLITUDE 0
-1
0 2 4 6 8 10 12 14 16 18 20
TIME INDEX
1
AMPLITUDE
-1
0 2 4 6 8 10 12 14 16 18 20
TIME INDEX
2
AMPLITUDE
-2
0 2 4 6 8 10 12 14 16 18 20
TIME INDEX
RESULT:
33
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
AIM: To verify Discrete Fourier Transform (DFT) and Inverse Discrete Fourier Transform
(IDFT) using MATLAB
TOOLS REQUIRED:
MATLAB Software,
Personal Computer.
MATLAB PROGRAM:
clc;
clear all;
close all;
x=input('enter the input sequence')
N=length(x);
% predefined function DFT
y1=fft(x);
y1
% user defined function DFT
for n=0:N-1
y(n+1)=0;
for k=0:N-1
y(n+1)=y(n+1)+x(k+1)*exp(-1i*2*pi*k*n/N);
end
end
% user defined function IDFT
for k=0:N-1
y2(k+1)=0;
for n=0:N-1
y2(k+1)=y2(k+1)+y(n+1)*exp(1i*2*pi*k*n/N);
end
end
y3=y2/N;
y3
m=20*log10(abs(y));
34
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
f =(0:length(y)-1)*100/length(y);
subplot(2,2,1)
stem(x)
xlabel(' sample index')
ylabel('amplitude')
title('Input sequence');grid on;
subplot(2,2,2)
plot(f,m) ;
xlabel(' Normalized Frequency')
ylabel('magnitude in dB ')
title('Magnitude Response of a given sequence x[n]');grid on;
subplot(2,2,3)
stem(abs(y3))
xlabel(' sample index')
ylabel('amplitude')
title('Inverse DFT plot');grid on;
subplot(2,2,4)
plot(f,angle(y)*(180/pi))
xlabel(' Normalized Frequency')
ylabel('Phase in Radians')
title('phase Response of a given sequence x[n]');grid on;
MODEL GRAPH:
0
amplitude
0.5
-200
0 -400
0 2 4 6 8 0 20 40 60 80 100
sample index Normalized Frequency
Inverse DFT plot phase Response of a given sequence x[n]
1.5 200
Phase in Radians
100
1
amplitude
0
0.5
-100
0 -200
0 2 4 6 8 0 20 40 60 80 100
sample index Normalized Frequency
RESULT:
35
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
clc;
clear all;
close all;
num=input('enter the numerator polynomial vector\n'); % [1 -2 1]
den=input('enter the denominator polynomial vector\n'); % [1 6 11 6]
H=tf(num,den)
[p z]=pzmap(H);
disp('zeros are at ');
disp(z);
disp('poles are at ');
disp(p);
pzmap(H);
if max(real(p))>=0
disp(' All the poles do not lie in the left half of S-plane ');
disp(' the given LTI system is not a stable system ');
else
disp('All the poles lie in the left half of S-plane ');
disp(' the given LTI system is a stable system ');
end;
36
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Pole-Zero Map
1
0.8
0.6
Imaginary Axis (seconds-1)
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
-3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1
-1
Real Axis (seconds )
0.8
0.6
0.4
Imaginary Part
0.2
2
0
-0.2
-0.4
-0.6
-0.8
-1
-1 -0.5 0 0.5 1
Real Part
RESULT:
38
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
PART -2 (FILTERS)
39
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
FREQUENCY RESPONSE OF IIR BUTTERWORTH
LOWPASS FILTER
AIM: To find frequency response of IIR low pass Butterworth filter using MATLAB
TOOLS REQUIRED:
MATLAB Software,
Personal Computer.
MATLAB PROGRAM FOR IIR BUTTERWORTH LOW PASS FILTER:
clc; clear all; close all;
fp=input('Enter the pass band frequency: ');
fs=input('Enter the stop band frequency: ');
rp=input('Enter the pass band ripple: ');
rs=input('Enter the stop band ripple: ');
f=input ('Enter the sample frequency: ');
wp=2*pi*fp;
ws=2*pi*fs;
w1=wp/f;
w2=ws/f;
[N,WN]=buttord(w1,w2,rp,rs);
[B,A]=butter(N,WN,'LOW');
w=0:0.01:pi;
[H1,om]=freqz(B,A,w);
m=20*log10(abs(H1));
an=angle(H1);
subplot(2,1,1);
plot(om/pi,m);
xlabel(' (a) Normalised frequency');
ylabel(' Gain in dB');
title('BUTTERWORTH LOW PASS FILTER');
grid;
subplot(2,1,2);
plot(om/pi,an);
xlabel(' (b) Normalised frequency');
ylabel(' Phase in radians');
grid;
40
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
INPUTS:
Enter the pass band frequency: 500
Enter the stop band frequency: 550
Enter the pass band ripple 0.1
Enter the stop band ripple 0.2
Enter the sample frequency 10000
MODEL GRAPH:
BUTTERWORTH LOW PASS FILTER
100
0
Gain in dB
-100
-200
-300
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(a) Normalised frequency
4
Phase in radians
-2
-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(b) Normalised frequency
RESULT:
41
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
FREQUENCY RESPONSE OF IIR BUTTERWORTH
HIGH PASS FILTER
AIM: To find the frequency response of IIR high pass Butterworth filter using MATLAB
TOOLS REQUIRED:
MATLAB Software,
Personal Computer.
MATLAB PROGRAM FOR IIR BUTTERWORTH HIGH PASS FILTERS:
clc; clear all; close all;
fp=input('Enter the pass band frequency:');
fs=input('Enter the stop band frequency:');
rp=input('Enter the pass band ripple:');
rs=input('Enter the stop band ripple:');
f=input ('Enter the sample frequency :');
wp=2*pi*fp;
ws=2*pi*fs;
w1=wp/f;
w2=ws/f;
[N,WN]=buttord(w1,w2,rp,rs);
[B,A]=butter(N,WN,'HIGH');
w=0:0.01:pi;
[H1,om]=freqz(B,A,w);
m=20*log10(abs(H1));
an=angle(H1);
subplot(2,1,1);
plot(om/pi,m);
xlabel(' (a) Normalised frequency');
ylabel(' Gain in dB');
title('BUTTERWORTH HIGH PASS FILTER');
grid;
subplot(2,1,2);
plot(om/pi,an);
xlabel(' (b) Normalised frequency');
ylabel(' Phase in radians');
grid;
42
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
INPUTS:
MODEL GRAPH:
0
Gain in dB
-50
-100
-150
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(a) Normalised frequency
4
Phase in radians
-2
-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(b) Normalised frequency
RESULT:
43
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
FREQUENCY RESPONSE OF IIR LOWPASS
CHEBYSHEV FILTER
AIM: To find the frequency response of IIR low pass Chebyshev filter using MATLAB
TOOLS REQUIRED:
MATLAB Software,
Personal Computer.
MATLAB PROGRAM FOR IIR CHEBYSHEV LOW PASS FILTER:
clc; clear all; close all;
fp=input('Enter the pass band frequency: ');
fs=input('Enter the stop band frequency: ');
rp=input('Enter the pass band ripple: ');
rs=input('Enter the stop band ripple: ');
f=input ('Enter the sample frequency: ');
wp=2*pi*fp;
ws=2*pi*fs;
w1=wp/f;
w2=ws/f;
[N,WN]=cheb1ord(w1,w2,rp,rs);
[B,A]=cheby1(N,rp,WN,'LOW');
w=0:0.01:pi;
[H,om]=freqz(B,A,w);
m=20*log10(abs(H));
an=angle(H);
subplot(2,1,1);
plot(om/pi,m);
xlabel(' (a) Normalised frequency');
ylabel(' Gain in dB');
title('CHEBYSHEV LOW PASS FILTER');
grid;
subplot(2,1,2);
plot(om/pi,an);
xlabel(' (b) Normalised frequency');
ylabel(' Phase in radians');
grid;
44
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
INPUTS:
Enter the pass band frequency: 500
Enter the stop band frequency: 550
Enter the pass band ripple: 0.1
Enter the stop band ripple: 0.2
Enter the sample frequency: 10000
MODEL GRAPH:
CHEBYSHEV LOW PASS FILTER
0
-50
Gain in dB
-100
-150
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(a) Normalised frequency
0
Phase in radians
-1
-2
-3
-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(b) Normalised frequency
RESULT:
45
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
FREQUENCY RESPONSE OF IIR HIGHPASS
CHEBYSHEV FILTER
AIM: To find the frequency response of IIR High pass Chebyshev Filter using MATLAB
TOOLS REQUIRED:
MATLAB Software,
Personal Computer.
MATLAB PROGRAM FOR IIR CHEBYSHEV HIGH PASS FILTER:
clc; clear all; close all;
fp=input('Enter the pass band frequency: ');
fs=input('Enter the stop band frequency: ');
rp=input('Enter the pass band ripple: ');
rs=input('Enter the stop band ripple: ');
f=input ('Enter the sample frequency: ');
wp=2*pi*fp;
ws=2*pi*fs;
w1=wp/f;
w2=ws/f;
[N,WN]=cheb1ord(w1,w2,rp,rs);
[B,A]=cheby1(N,rp,WN,'high');
w=0:0.01:pi;
[H,om]=freqz(B,A,w);
m=20*log10(abs(H));
an=angle(H);
subplot(2,1,1);
plot(om/pi,m);
xlabel(' (a) Normalised frequency');
ylabel(' Gain in dB');
title('CHEBYSHEV TYPE-1 HIGH PASS FILTER');
grid;
subplot(2,1,2);
plot(om/pi,an);
xlabel(' (b) Normalised frequency');
ylabel(' Phase in radians');
grid;
46
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
INPUTS:
Enter the pass band frequency: 550
Enter the stop band frequency: 500
Enter the pass band ripple: 0.1
Enter the stop band ripple: 0.2
Enter the sample frequency: 10000
MODEL GRAPH:
CHEBYSHEV TYPE-1 HIGH PASS FILTER
0
-20
Gain in dB
-40
-60
-80
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(a) Normalised frequency
4
Phase in radians
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(b) Normalised frequency
RESULT:
47
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
AIM: To write a program to design a FIR Low pass filter using Rectangular windowing
technique.
TOOLS REQUIRED:
MATLAB Software,
Personal Computer.
ALGORITHM:
1. Get the pass band and stop band ripples.
2. Get the pass band and stop band edge frequencies.
3. Get the sampling frequency.
4. Calculate the order of filter.
5. Find filter coefficients.
6. Draw the magnitude and phase response.
MATLAB PROGRAM FOR FIR FILTER USING RECTANGULAR WINDOW:
clc; clear all; close all;
fp=input('Enter the pass band frequency: ');
fs=input('Enter the stop band frequency: ');
rp=input('Enter the pass band ripple: ');
rs=input('Enter the stop band ripple: ');
f=input ('Enter the sample frequency: ');
wp=2*fp;
ws=2*fs;
w1=wp/f;
w2=ws/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;
48
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
end
y=boxcar(n1);
n1
b=fir1(n,w1,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
plot(o/pi,m);
ylabel('Gain in dB -->');
xlabel('Normalised frequency');
title('FIR FILTER USING RECTANGULAR WINDOW');
INPUTS:
Enter the pass band frequency: 40
Enter the stop band frequency: 30
Enter the pass band ripple: 2
Enter the stop band ripple: 3
Enter the sample frequency: 500
MODEL GRAPH:
FIR FILTER USING RECTANGULAR WINDOW
20
-20
Gain in dB -->
-40
-60
-80
-100
-120
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalised frequency
RESULT:
49
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
AIM: To write a program to design a FIR Low pass filter using Triangular windowing
technique.
TOOLS REQUIRED:
MATLAB Software,
Personal Computer.
ALGORITHM:
1. Get the pass band and stop band ripples.
2. Get the pass band and stop band edge frequencies.
3. Get the sampling frequency.
4. Calculate the order of filter.
5. Find filter coefficients.
6. Draw the magnitude and phase response
MATLAB PROGRAM FOR FIR FILTER USING TRIANGULAR WINDOW:
clc;
clear all;
close all;
fp=input('Enter the pass band frequency: ');
fs=input('Enter the stop band frequency: ');
rp=input('Enter the pass band ripple: ');
rs=input('Enter the stop band ripple: ');
f=input ('Enter the sample frequency: ');
wp=2*fp;
ws=2*fs;
w1=wp/f;
w2=ws/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;
50
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
n=n-1;
end
%low pass filter
y=triang(n1);
n1
b=fir1(n,w1,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
plot(o/pi,m);
ylabel('Gain in dB -->');
xlabel('Normalised frequency');
title('FIR FILTER LOWPASS FILTER USING TRIANGLAR WINDOW');
INPUTS:
Enter the pass band frequency: 40
Enter the stop band frequency: 30
Enter the pass band ripple: 2
Enter the stop band ripple: 3
Enter the sample frequency: 500
MODEL GRAPH:
-10
-20
Gain in dB -->
-30
-40
-50
-60
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalised frequency
RESULT:
51
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
PART -3
(IMAGE PROCESSING)
52
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
clc;
clear;
close all;
I=imread('cameraman.tif');
% A 256 gray-level image:
[I256,map256]=gray2ind(I,256);
[I128,map128]=gray2ind(I,128);
[I64,map64]=gray2ind(I,64);
[I32,map32]=gray2ind(I,32);
[I16,map16]=gray2ind(I,16);
[I8,map8]=gray2ind(I,8);
[I4,map4]=gray2ind(I,4);
[I2,map2]=gray2ind(I,2);
subplot(241);subimage(I256,map256);title('256');
subplot(242);subimage(I128,map128);title('128');
subplot(243);subimage(I64,map64);title('64');
subplot(244);subimage(I32,map32);title('32');
subplot(245);subimage(I16,map16);title('16');
subplot(246);subimage(I8,map8);title('8');
subplot(247);subimage(I4,map4);title('4');
subplot(248);subimage(I2,map2);title('2');
53
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
OUTPUT:
RESULT:
54
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
end
I_out = zeros(m,n);
for i = 1:m
for j = 1:n
I_out(i,j) = out_int(I(i,j) + 1);
end
end
subplot(131);
imshow(uint8(I));
title('original image');
subplot(132);
imshow(uint8(I_out));
title('histogram equalized image');
K1 = histeq(I1);
subplot(133);
imshow(K1);
title('matlab generated');
OUTPUT:
ANOTHER METHOD:
clc;
clear all;
close all;
I = imread('tire.tif');
J = histeq(I);
title('Original Image');
imshow(I)
56
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
RESULT:
57
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
OUTPUT VALUES:
psnr_noise = 20.3766
psnr_filter = 24.3529
58
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
OUTPUT:
psnr_min
OUTPUT VALUES:
psnr_noise = 17.9269
psnr_median = 21.7282
psnr_max = 10.4916
psnr_min = 11.3655
OUTPUT:
ANOTHER METHOD:
RESULT:
60
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
61
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
OUTPUT:
62
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
OUTPUT:
63
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
OUTPUT:
64
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
ANOTHER METHOD:
RESULT:
65
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
TOOLS REQUIRED:
MATLAB Software,
Personal Computer.
MATLAB PROGRAM TO PERFORM THE IMAGE MOTION BLUR AND
CALCULATE PSNR TO THE NOISE IMAGE AND ALSO NOISE FREE IMAGE
clc;
clear;
close all;
%matlab program for debluring a motion blurred image using wiener filter
I = im2double(imread('cameraman.tif'));
% Simulate a Motion blur % defining the width of blurred pixels
LEN = 20;
% defining the angle of blur
THETA = 10;
PSF = fspecial('motion', LEN, THETA);
blurred = imfilter(I, PSF, 'conv', 'circular');
%restoring the blurred image using wiener filter
wnr1 = deconvwnr(blurred, PSF, 0);
imshow([I blurred wnr1]);
title('original image, motion blurred, deblurred using wiener filter');
OUTPUT:
66
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
ANOTHER METHOD:
clc;
clear all;
close all;
% Read an image into the MATLAB workspace
I = imread('cameraman.tif');
figure; imshow(I); title('Original Image');
% Motion Blur
h = fspecial('motion');
aw1 = imfilter(I,h);
figure;
imshow(aw1);
title('Motion Blurred Image');
A=I;
B=aw1;
ref=I;
A=aw1;
%Calculate the PSNR.
[peaksnr, snr] = psnr(A, ref);
fprintf('\n The Peak-SNR value is %0.4f', peaksnr);
fprintf('\n The SNR value is %0.4f \n', snr);
RESULT:
67
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Expt.No: Date:
clc;
clear;
close all
a = imread('cameraman.tif');
a = im2double(a);
% 1st level DWT Decomposition
[LL1, LH1, HL1, HH1] = dwt2(a,'db1');
imshow([LL1 LH1;HL1 HH1]);
title('1st level DWT with db4 wavelet');
% 2nd level DWT Decomposition
[LL2, LH2, HL2, HH2] = dwt2(LL1,'db1');
temp = [LL2 LH2;HL2 HH2];
figure;
imshow([temp LH1;HL1 HH1]);
title('2nd level DWT with db4 wavelet');
% reconstruction using inverse dwt
rec_1 = idwt2(LL2, LH2, HL2, HH2,'db1');
figure;imshow(rec_1);
title('reconstruction level 1');
% reconstruction using inverse dwt
rec_2 = idwt2(rec_1, LH1, HL1, HH1,'db1');
68
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
figure;imshow(rec_2);
title('reconstruction level 2');
psnr_rec = psnr(a,rec_2)
OUTPUT:
69
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
psnr_rec = 309.9025
RESULT:
70
ADITYA COLLEGE OF ENGINEERING AND TECHNOLOGY