Вы находитесь на странице: 1из 45

DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY (A)


DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB (R16)


IV ECE (SEM-1)

1 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

LIST OF EXPERIMENTS

MINIMUM 4 EXPERIMENTS SHOULD BE DONE FROM EACH PART

PART-1( SIGNALS )
1) Generation of discrete time signals
2) To verify the Linear Convolution
a) Using MATLAB
b) Using Code Composer Studio (CCS)
3) To verify the Circular Convolution for discrete signals
a) Using MATLAB
b) Using Code Composer Studio (CCS)
4) To Find the addition of Sinusoidal Signals
5) To verify Discrete Fourier Transform(DFT) and Inverse Discrete Fourier Transform(IDFT)
a) Using MATLAB
b) Using Code Composer Studio (CCS)
6) Transfer Function Stability Analysis: using pole-zero plot, bode plot, 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
15) To verify the Normalized Cross Correlation to the addition of noise and removal of noise
using filters to an image.
16) Compute the edge of an image using spatial filters.
17) Perform the image motion blur and calculate PSNR to the noise image and also noise free
image.
18) To verify the PSNR to the Second order Decomposition of Discrete Wavelet transforms and
to the reconstructedimage using inverse Discrete Wavelet transform

2 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Experiment No.-1

GENERATION OF DISCRETE TIME SIGNALS


Aim: To write a MATLAB Program for generation of discrete time signals

Tools: MATLAB Software


PC

Theory:
1. Discrete time views values of variables as occurring at distinct, separate "points in time", or
equivalently as being unchanged throughout each non-zero region of time ("time period")—
that is, time is viewed as a discrete variable.
2. A discrete signal or discrete-time signal is a time series consisting of a sequence of
quantities.
3. Discrete-time signals may have several origins, but can usually be classified into one of two
groups
a. By acquiring values of an analog signal at constant or variable rate. This process is
called sampling
b. By observing an inherently discrete-time process, such as the weekly peak value of
a particular economic indicator.

Program:

(a) SINUSOIDAL SIGNAL


x=0:0.1:10;
y=sin(x);
subplot(4,2,1);
stem(x, y);
xlabel('TIME');
ylabel('AMPLITUDE');
title('SINE WAVE');

(b) COSINE WAVE


x=0:0.1:10;
y=cos(x);
subplot(4,2,2);
stem(x, y);
xlabel('TIME');
ylabel('AMPLITUDE');
title('cosine wave');

(c) UNIT STEP SIGNAL


t=0:1:10;
x=[t>=0];
subplot(4,2,3);
stem(t, x);
title('unit step');

3 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

xlabel('TIME');
ylabel('AMPLITUDE');

(d) RAMP SIGNAL


t=0:0.1:10;a=1;
y=a*t;
subplot(4,2,4);
stem (t,y);
title('ramp signal');
xlabel('TIME');
ylabel('AMPLITUDE');

(e) EXPONENTIAL SIGNAL


t=0:0.1:10;
a=1;
y=exp(a*t);
subplot(4,2,5);
stem (t,y);
title('exponential signal');
xlabel('TIME');
ylabel('AMPLITUDE');

(f) PARABOLIC SIGNAL

t=0:0.1:10;a=1;
y=a*t.^2;
subplot(4,2,6);
stem(t,y);
title('parabola signal');
xlabel('TIME');
ylabel('AMPLITUDE');

(g) IMPULSE SIGNAL


a=[-2:1:2];
b=[zeros(1,2),ones(1,1),zeros(1,2)];
subplot(4,2,7);
stem(a,b);
title('impulse signal');
xlabel('TIME');
ylabel('AMPLITUDE');

(h) SQUARE SIGNAL


t=0:0.01:2;
x=square(4*pi*t);
4 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY
DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

subplot(4,2,8);
plot(t,x);
title('square wave');
xlabel('TIME');
ylabel('AMPLITUDE');

Model Graph:

Procedure:

1. Click on the START menu and run the MATLAB Software.


2. A command page appears, now CLICK on the New Script then Editor Window will
open.
3. Analyse the problem and design the program and then write the program with
prescribed MATLAB functions and operators.
4. Save the program in “.m” format and click on RUN key.
5. To check the errors in the program, copy the program in Command Window, it
checks the errors if any and give the suggestions to rectify the errors if any.
6. If there are no errors, give the input parameters depending on requirement.
7. Now the OUTPUT waveform will appear on the screen
8. Observe the Output Waveform.
9. Repeat the same process for different input parameters.

RESULT:

Hence the MATLAB program for generation of various discrete signals is


verified under different conditions.

5 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Experiment No.-2

LINEAR CONVOLUTION
Aim: To write a MATLAB Program for Linear convolution using MATLAB.

Tools: MATLAB Software


PC

Theory:
1. Linear convolution is the basic operation to calculate the output for any linear time
invariant system given its input and its impulse response.
2. Convolution is used to find out the output of an LTI system.If the response of the system
to the impulse signal is known(h(t)h(t) or h(n)h(n)),then the response to any other input
to the system can be found out by convolving the input signal with impulse response.
3. Most often it is considered because it is a mathematical consequence of the discrete
Fourier transform
4. One of the most efficient ways to implement convolution is by doing multiplication in
the frequency.
Program:

(a) Using Built-In functions

x=[1 2 3 4];
n1=length(x);
subplot(3,1,1);
stem(x);
title('First sequence');

h=[5 6 7 8];
n2=length(h);
subplot(3,1,2);
stem(h);
title(‘Second sequence');

y=conv(x,h);
disp(y);
n=1:1:n1+n2-1;
subplot(3,1,3);
stem(n,y);
title('LINEAR CONVOLUTION:')

6 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Model Graph:

(b) Using Standard Procedure

x=[1 2 3 4];
n=length(x);
subplot(3,1,1);stem(x);

h=[5 6 7 8];
k=length(h);
subplot(3,1,2);stem(h);

x=[x,zeros(1,n)];
h=[h,zeros(1,k)];
y=zeros(1,k+n-1);
for i=1:k+n-1
y(i)=0;
for j=1:k+n-1
if(j<i+1)
y(i)=y(i)+x(j)*h(i-j+1);
end
end
end
disp(y)
subplot(3,1,3);stem(y);
title('LINEAR CONVOLUTION:')

7 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Model Graph:

PROCEDURE:

1. Click on the START menu and run the MATLAB Software.


2. A command page appears, now CLICK on the New Script then Editor Window will
open.
3. Analyse the problem and design the program and then write the program with
prescribed MATLAB functions and operators.
4. Save the program in “.m” format and click on RUN key.
5. To check the errors in the program, copy the program in Command Window, it
checks the errors if any and give the suggestions to rectify the errors if any.
6. If there are no errors, give the input parameters depending on requirement.
7. Now the OUTPUT waveform will appear on the screen
8. Observe the Output Waveform.
9. Repeat the same process for different input parameters.

RESULT:

Hence the MATLAB program for Linear convolution using MATLAB functions
is verified under different conditions.

8 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Experiment No.-3

CIRCULAR CONVOLUTION
Aim: To write a MATLAB Program for Circular Convolution using MATLAB.

Tools: MATLAB Software


PC

Theory:
1. The circular convolution, also known as cyclic convolution, of two aperiodic functions
(i.e. Schwartz functions) occurs when one of them is convolved in the normal way with
a periodic summation of the other function
2. The circular convolution is defined on time-limited sequences of length NN.
3. The circular convolution is periodic with period NN.
4. In the circular convolution, the shifted sequence wraps around the summation window,
when it would leave the region.
5. In the finite discrete domain, the convolution theorem holds for the circular convolution,
not for the linear convolution. Linear convolution can be obtained by appropriate zero-
padding of the sequences.

Program:

(a) Using MATLAB Built-In functions


x=[1 2 3 4];
n1=length(x);
subplot(2,2,1);
stem(x);
title('First sequence');

h=[5 6 7 8];
n2=length(h);
subplot(2,2,2);
stem(h);
title('Second sequence');

n=max(n1,n2);
y=cconv(x,h,n);
subplot(2,2,3);
stem(y,'r');
title('circular convolution');

z=cconv(x,h);
subplot(2,2,4);
stem(z);
title('linear convolution');

9 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Model Graph:

(b) Using Standard Procedure


clc;
clear all;
a=[1 2 3 4];
n=length(a);
subplot(3,1,1);stem(a);

b=[5 6 7 8];
k=length(b);
subplot(3,1,2);stem(b);

N=max(n,k);
y=zeros(1,N);

for n=0:N-1
y(n+1)=0;
for i=0:N-1
j=mod(n-i,N);
y(n+1)=y(n+1)+a(i+1)*b(j+1);
end
end

subplot(3,1,3);stem(y);
disp(y);

10 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Model Graph:

Procedure:

1. Click on the START menu and run the MATLAB Software.


2. A command page appears, now CLICK on the New Script then Editor Window will
open.
3. Analyse the problem and design the program and then write the program with
prescribed MATLAB functions and operators.
4. Save the program in “.m” format and click on RUN key.
5. To check the errors in the program, copy the program in Command Window, it
checks the errors if any and give the suggestions to rectify the errors if any.
6. If there are no errors, give the input parameters depending on requirement.
7. Now the OUTPUT waveform will appear on the screen.
8. Observe the Output Waveform.
9. Repeat the same process for different input parameters.

RESULT:

Hence the MATLAB program for Circular Convolution using MATLAB


functions is verified under different conditions.

11 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Experiment No.-4

SUMMATION OF SINUSOIDAL SIGNALS


Aim: To write a MATLAB Program for summation of sinusoidal signals using MATLAB.

Tools: MATLAB Software


PC

Program:

(A)
clc;
clear all;
close all;

x=(-6*pi):0.01:(6*pi);

y=sin(x);
y1=sin(x)+(1/3)*sin(3*x)+(1/5)*sin(5*x);
y2=sin(x)+(1/3)*sin(3*x)+(1/5)*sin(5*x)+(1/7)*sin(7*x)+(1/9)*sin(9*x);
y3=sin(x)+(1/3)*sin(3*x)+(1/5)*sin(5*x)+(1/7)*sin(7*x)+(1/9)*sin(9*x)+(1/11)*sin(11*x)+(1/1
3)*sin(13*x);

subplot(2,2,1);plot(x,y);title('sine wave');
subplot(2,2,2);plot(x,y1);title('3 sine wave');
subplot(2,2,3);plot(x,y2);title('5 sine wave');
subplot(2,2,4);plot(x,y3);title('7 sine wave');

Model Graph:

12 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

(B)

x=(-6*pi):0.01:(6*pi);
y=sin(x);
y1=sin(x)+(1/3)*sin(3*x);
y2=sin(x)+(1/3)*sin(3*x)+(1/5)*sin(5*x);
y3=sin(x)+(1/3)*sin(3*x)+(1/5)*sin(5*x)+(1/7)*sin(7*x);
y4=sin(x)+(1/3)*sin(3*x)+(1/5)*sin(5*x)+(1/7)*sin(7*x)+(1/9)*sin(9*x);
y5=sin(x)+(1/3)*sin(3*x)+(1/5)*sin(5*x)+(1/7)*sin(7*x)+(1/9)*sin(9*x)+(1/11)*sin(11*x);
y6=sin(x)+(1/3)*sin(3*x)+(1/5)*sin(5*x)+(1/7)*sin(7*x)+(1/9)*sin(9*x)+(1/11)*sin(11*x)+(1/1
3)*sin(13*x);
y7=sin(x)+(1/3)*sin(3*x)+(1/5)*sin(5*x)+(1/7)*sin(7*x)+(1/9)*sin(9*x)+(1/11)*sin(11*x)+(1/1
3)*sin(13*x)+(1/15)*sin(15*x);

subplot(4,2,1);plot(x,y);title('sinewave');
subplot(4,2,2);plot(x,y1);title('2 TERMS');
subplot(4,2,3);plot(x,y2);title('3 TERMS');
subplot(4,2,4);plot(x,y3);title('4 sinewave');
subplot(4,2,5);plot(x,y4);title('5 sinewave');
subplot(4,2,6);plot(x,y5);title('6 sinewave');
subplot(4,2,7);plot(x,y6);title('7 sinewave');
subplot(4,2,8);plot(x,y7);title(' 8sinewave');

z=fft(y);z=fftshift(z);
z1=fft(y1);z1=fftshift(z1);
z2=fft(y2);z2=fftshift(z2);
z3=fft(y3);z3=fftshift(z3);
z4=fft(y4);z4=fftshift(z4);
z5=fft(y5);z5=fftshift(z5);
z6=fft(y6);z6=fftshift(z6);
z7=fft(y7);z7=fftshift(z7);

fre=linspace(-1,1,length(z));
figure,axis([0 0.1 0 10]);

subplot(4,2,1);plot(fre,z);axis([0 0.1 0 1]);


subplot(4,2,2);plot(fre,z1);axis([0 0.1 0 1]);
subplot(4,2,3);plot(fre,z2);axis([0 0.1 0 1]);
subplot(4,2,4);plot(fre,z3);axis([0 0.1 0 1]);
subplot(4,2,5);plot(fre,z4);axis([0 0.1 0 1]);
subplot(4,2,6);plot(fre,z5);axis([0 0.1 0 1]);
subplot(4,2,7);plot(fre,z6);axis([0 0.1 0 1]);
subplot(4,2,8);plot(fre,z7);axis([0 0.1 0 1]);

13 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

14 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

(C)

x=(-6*pi):0.01:(6*pi);
y=cos(x);

y1=(1/2)*cos(2*x)+(1/4)*cos(4*x);
y2=(1/2)*cos(2*x)+(1/4)*cos(4*x)+(1/6)*cos(6*x);
y3=(1/2)*cos(2*x)+(1/4)*cos(4*x)+(1/6)*cos(6*x)+(1/8)*cos(8*x);
y4=(1/2)*cos(2*x)+(1/4)*cos(4*x)+(1/6)*cos(6*x)+(1/8)*cos(8*x)+(1/10)*cos(10*x);
y5=(1/2)*cos(2*x)+(1/4)*cos(4*x)+(1/6)*cos(6*x)+(1/8)*cos(8*x)+(1/10)*cos(10*x)+(1/12)*c
os(12*x);
y6=(1/2)*cos(2*x)+(1/4)*cos(4*x)+(1/6)*cos(6*x)+(1/8)*cos(8*x)+(1/10)*cos(10*x)+(1/12)*c
os(12*x)+(1/14)*cos(14*x);
y7=(1/2)*cos(2*x)+(1/4)*cos(4*x)+(1/6)*cos(6*x)+(1/8)*cos(8*x)+(1/10)*cos(10*x)+(1/12)*c
os(12*x)+(1/14)*cos(14*x)+(1/16)*cos(16*x);

subplot(4,2,1);plot(x,y);title('cosewave');
subplot(4,2,2);plot(x,y1);title('2 TERMS');
subplot(4,2,3);plot(x,y2);title('3 TERMS');
subplot(4,2,4);plot(x,y3);title('4 cosewave');
subplot(4,2,5);plot(x,y4);title('5 cosewave');
subplot(4,2,6);plot(x,y5);title('6 cosewave');
subplot(4,2,7);plot(x,y6);title('7 cosewave');
subplot(4,2,8);plot(x,y7);title(' 8cosewave');

z=fft(y);z=fftshift(z);
z1=fft(y1);z1=fftshift(z1);
z2=fft(y2);z2=fftshift(z2);
z3=fft(y3);z3=fftshift(z3);
z4=fft(y4);z4=fftshift(z4);
z5=fft(y5);z5=fftshift(z5);
z6=fft(y6);z6=fftshift(z6);
z7=fft(y7);z7=fftshift(z7);

fre=linspace(-1,1,length(z));
figure,axis([0 0.1 0 10]);

subplot(4,2,1);plot(fre,z);axis([0 0.1 0 10]);


subplot(4,2,2);plot(fre,z1);axis([0 0.1 0 10]);
subplot(4,2,3);plot(fre,z2);axis([0 0.1 0 10]);
subplot(4,2,4);plot(fre,z3);axis([0 0.1 0 10]);
subplot(4,2,5);plot(fre,z4);axis([0 0.1 0 10]);
subplot(4,2,6);plot(fre,z5);axis([0 0.1 0 10]);
subplot(4,2,7);plot(fre,z6);axis([0 0.1 0 10]);
subplot(4,2,8);plot(fre,z7);axis([0 0.1 0 10

15 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

16 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Procedure:

1. Click on the START menu and run the MATLAB Software.


2. A command page appears, now CLICK on the New Script then Editor Window will
open.
3. Analyse the problem and design the program and then write the program with
prescribed MATLAB functions and operators.
4. Save the program in “.m” format and click on RUN key.
5. To check the errors in the program, copy the program in Command Window, it
checks the errors if any and give the suggestions to rectify the errors if any.
6. If there are no errors, give the input parameters depending on requirement
7. Now the OUTPUT waveform will appear on the screen.
8. Observe the Output Waveform.
9. Repeat the same process for different input parameters.

RESULT:

Hence the MATLAB program for the summation of sinusoidal signals is


examined.

17 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Experiment No.-5

DISCRETE FOURIER TRANSFORM & IDFT


Aim: To write a MATLAB Program for Discrete Fourier Transform and IDFT using
MATLAB.

Tools: MATLAB Software


PC

Program:

clc;
clear all;
close all;

x=input('enter N-point input sequence');


N=input('enter length of N-point fft');
subplot(3,1,1);stem(x);
title('input sequence');

y=fft(x,N);
disp(‘THE DFT SEQUENCE IS:’);
disp(y);
m=abs(y);
an=angle(y);

subplot(3,1,2);
stem(real(y));
title('Real part of fft sequence');

subplot(3,1,3);
stem(imag(y));
title('Imaginary part of fft sequence');

z=ifft(y,N)
disp(‘THE IDFT SEQUENCE IS:’);
disp(z);
m1=abs(z);
an1=angle(z);

figure,
subplot(3,1,1);stem(y);
title('input sequence');
subplot(3,1,2);
stem(real(z));

18 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

title('Real part of ifft sequence');

subplot(3,1,3);
stem(imag(z));
title('Imaginary part of ifft sequence');

Output:

enter N-point input sequence [2 2 2 2 1 1 1 1]

enter length of N-point fft 8

THE DFT SEQUENCE IS:

12.0000 + 0.0000i 1.0000 - 2.4142i 0.0000 + 0.0000i 1.0000 - 0.4142i 0.0000 + 0.0000i
1.0000 + 0.4142i 0.0000 + 0.0000i 1.0000 + 2.4142i

THE IDFT SEQUENCE IS:

2 2 2 2 1 1 1 1

Model Graph:

19 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Procedure:

1. Click on the START menu and run the MATLAB Software.


2. A command page appears, now CLICK on the New Script then Editor Window will
open.
3. Analyse the problem and design the program and then write the program with
prescribed MATLAB functions and operators.
4. Save the program in “.m” format and click on RUN key.
5. To check the errors in the program, copy the program in Command Window, it
checks the errors if any and give the suggestions to rectify the errors if any.
6. If there are no errors, give the input parameters depending on requirement.
7. Now the OUTPUT waveform will appear on the screen.
8. Observe the Output Waveform.
9. Repeat the same process for different input parameters.

RESULT:

Hence the MATLAB program for DFT & IDFT using MATLAB functions is
verified under different conditions.

20 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Experiment No.-6

TRANSFER FUNCTION STABILITY ANALYSIS


Aim: To write a MATLAB Program for Transfer function stability analysis uses POLE-ZERO
PLOT, BODE PLOT, NYQUIST PLOT and Z-PLANE PLOT using MATLAB.

Tools: MATLAB Software


PC

Program:

num=[0 2 4];
den=[2 3 1];
r=tf(num,den);
subplot(2,2,1);bode(r);
subplot(2,2,2);nyquist(r);
subplot(2,2,3);rlocus(r);

Model Graph:

Procedure:

1. Click on the START menu and run the MATLAB Software.


2. A command page appears, now CLICK on the New Script then Editor Window will
open.
3. Analyse the problem and design the program and then write the program with
prescribed MATLAB functions and operators.

21 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

4. Save the program in “.m” format and click on RUN key.


5. To check the errors in the program, copy the program in Command Window, it
checks the errors if any and give the suggestions to rectify the errors if any.
6. If there are no errors, give the input parameters depending on requirement.
7. Now the OUTPUT waveform will appear on the screen.
8. Observe the Output Waveform.
9. Repeat the same process for different input parameters.

RESULT:

Hence the MATLAB program for Transfer function stability analysis using
POLE-ZERO PLOT, BODE PLOT, NYQUIST PLOT and Z-PLANE PLOT using
MATLAB functions is verified under different conditions.

22 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Experiment No.-7

FREQUENCY RESPONSE OF IIR LOW PASS BUTTERWORTH FILTER


Aim: To write a MATLAB Program for frequency response of IIR Butterworth LPF.

Tools: MATLAB Software


PC

Theory:
1. The Butterworth filter is a type of signal processing filter designed to have a frequency
response as flat as possible in the passband. It is also referred to as a maximally flat
magnitude filter.
2. It was first described in 1930 by the British engineer and physicist Stephen Butterworth in
his paper entitled "On the Theory of Filter Amplifiers"
3. The frequency response of the Butterworth filter is maximally flat (i.e. has no ripples) in the
passband and rolls off towards zero in the stopband
4. A first-order filter's response rolls off at −6 dB per octave (−20 dB per decade) (all first-
order lowpass filters have the same normalized frequency response). A second-order filter
decreases at −12 dB per octave, a third-order at −18 dB and so on.
5. Butterworth filters have a monotonically changing magnitude function with ω, unlike other
filter types that have non-monotonic ripple in the passband and/or the stopband.
Program:

clc;
clear all;
close all;

F=input('enter sampling frequency');


fp=input('enter passband frequency');
fs=input('enter stopband frequency');
rp=input('enter passband ripple');
rs=input('enter stopband ripple');

wp=(2*fp)/F;
ws=(2*fs)/F;

[N,wn]=buttord(wp,ws,rp,rs);
disp('the order of filter is:');disp(N);
disp('the cutoff frequency of filter is:');disp(wn);

[b,a]=butter(N,wn);
w=0:0.01:pi;
[h,w1]=freqz(b,a,w);

k=20*log(abs(h));

23 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

subplot(2,1,1);plot(w/pi*F/2,k);grid on;title('magnitude
plot');xlabel('frequency');ylabel('amplitude');

g=angle(h);
subplot(2,1,2);plot(w/pi*F/2,g);grid on;title('phase plot');xlabel('frequency');ylabel('angle');

Output:
INPUTS: F=10000
fp=400
fs=1000
rp=4
rs=30

OUTPUTS: N=4
Wn=0.0867
Model Graph:

Procedure:

1. Click on the START menu and run the MATLAB Software.


2. A command page appears, now CLICK on the New Script then Editor Window will open.
3. Analyse the problem and design the program and then write the program with prescribed
MATLAB functions and operators.
4. Save the program in “.m” format and click on RUN key.
5. To check the errors in the program, copy the program in Command Window, it checks the
errors if any and give the suggestions to rectify the errors if any.
6. If there are no errors, give the input parameters depending on requirement
7. Now the OUTPUT waveform will appear on the screen.
8. Observe the Output Waveform.
9. Repeat the same process for different input parameters.

RESULT: Hence the MATLAB program for frequency response of IIR Butterworth LPF
using MATLAB functions is verified under different conditions.
24 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY
DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Experiment No.-8

FREQUENCY RESPONSE OF IIR HIGH PASS BUTTERWORTH FILTER


Aim: To write a MATLAB Program for frequency response of IIR Butterworth HPF.

Tools: MATLAB Software


PC

Theory:
1. The Butterworth filter is a type of signal processing filter designed to have a frequency
response as flat as possible in the passband. It is also referred to as a maximally flat
magnitude filter.
2. It was first described in 1930 by the British engineer and physicist Stephen Butterworth in
his paper entitled "On the Theory of Filter Amplifiers"
3. The frequency response of the Butterworth filter is maximally flat (i.e. has no ripples) in the
passband and rolls off towards zero in the stopband
4. A first-order filter's response rolls off at −6 dB per octave (−20 dB per decade) (all first-
order lowpass filters have the same normalized frequency response). A second-order filter
decreases at −12 dB per octave, a third-order at −18 dB and so on.
5. Butterworth filters have a monotonically changing magnitude function with ω, unlike other
filter types that have non-monotonic ripple in the passband and/or the stopband.
Program:
clc;clear all;close all;

F=input('enter sampling frequency');


fp=input('enter passband frequency');
fs=input('enter stopband frequency');
rp=input('enter passband ripple');
rs=input('enter stopband ripple');

wp=(2*fp)/F;
ws=(2*fs)/F;

[N,wn]=buttord(wp,ws,rp,rs);
disp('the order of filter is:');disp(N);
disp('the cutoff frequency of filter is:');disp(wn);

[b,a]=butter(N,wn,'high');
w=0:0.01:pi;
[h,w1]=freqz(b,a,w);

k=20*log(abs(h));
subplot(2,1,1);plot(w/pi*F/2,k);grid on;title('magnitude
plot');xlabel('frequency');ylabel('amplitude');

g=angle(h);
25 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY
DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

subplot(2,1,2);plot(w/pi*F/2,g);grid on;title('phase plot');xlabel('frequency');ylabel('angle');

Output:
INPUTS: F=10000
fp=1000
fs=400
rp=4
rs=30

OUTPUTS: N=4
Wn=0.1853
Model Graph:

Procedure:

1. Click on the START menu and run the MATLAB Software.


2. A command page appears, now CLICK on the New Script then Editor Window will open.
3. Analyse the problem and design the program and then write the program with prescribed
MATLAB functions and operators.
4. Save the program in “.m” format and click on RUN key.
5. To check the errors in the program, copy the program in Command Window, it checks the
errors if any and give the suggestions to rectify the errors if any.
6. If there are no errors, give the input parameters depending on requirement
7. Now the OUTPUT waveform will appear on the screen.
8. Observe the Output Waveform.
9. Repeat the same process for different input parameters.

RESULT: Hence the MATLAB program for frequency response of IIR Butterworth HPF
using MATLAB functions is verified under different conditions.

26 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Experiment No.-9

FREQUENCY RESPONSE OF IIR LOW PASS CHEBYSHEV FILTER


Aim: To write a MATLAB Program for frequency response of IIR CHEBYSHEV LPF.

Tools: MATLAB Software


PC

Theory:

1. Chebyshev filters are analog or digital filters having a steeper roll-off and
more passband ripple (type I) or stopband ripple (type II) than Butterworth filters.
2. Chebyshev filters have the property that they minimize the error between the idealized and
the actual filter characteristic over the range of the filter but with ripples in the passband
3. The type I Chebyshev filters are called usually as just "Chebyshev filters", the type II ones
are usually called "inverse Chebyshev filters".
4. Because of the passband ripple inherent in Chebyshev filters, the ones that have a smoother
response in the passband but a more irregular response in the stopband are preferred for
some applications
Program:

(A) CHEBYSHEV TYPE-1


clc;
clear all;
close all;

F=input('enter sampling frequency');


fp=input('enter passband frequency');
fs=input('enter stopband frequency');
rp=input('enter passband ripple');
rs=input('enter stopband ripple');

wp=(2*fp)/F;
ws=(2*fs)/F;

[N,wn]=cheb1ord(wp,ws,rp,rs);

disp('the order of filter is:');disp(N);


disp('the cutoff frequency of filter is:');disp(wn);

[b,a]=cheby1(N,rp,wn);
w=0:0.01:pi;
[h,w1]=freqz(b,a,w);

k=20*log(abs(h));
subplot(2,1,1);plot(w/pi*F/2,k);grid on;

27 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

title('magnitude plot'); xlabel('frequency'); ylabel('amplitude');

g=angle(h);
subplot(2,1,2);plot(w/pi*F/2,g);grid on;title('phase plot');xlabel('frequency');ylabel('angle');

Output:
INPUTS: F=10000
fp=400
fs=1000
rp=4
rs=30

OUTPUTS: N=3
Wn=0.080

Model Graph:

(B) CHEBYSHEV TYPE-2


clc;
clear all;
close all;

F=input('enter sampling frequency');


fp=input('enter passband frequency');
fs=input('enter stopband frequency');
rp=input('enter passband ripple');
rs=input('enter stopband ripple');

wp=(2*fp)/F;

28 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

ws=(2*fs)/F;

[N,wn]=cheb2ord(wp,ws,rp,rs);

disp('the order of filter is:');disp(N);


disp('the cutoff frequency of filter is:');disp(wn);

[b,a]=cheby2(N,rs,wn);
w=0:0.01:pi;
[h,w1]=freqz(b,a,w);

k=20*log(abs(h));
subplot(2,1,1);plot(w/pi*F/2,k);grid on;
title('magnitude plot'); xlabel('frequency'); ylabel('amplitude');

g=angle(h);
subplot(2,1,2);plot(w/pi*F/2,g);grid on;title('phase plot');xlabel('frequency');ylabel('angle');

Output:
INPUTS: F=10000
fp=400
fs=1000
rp=4
rs=30

OUTPUTS: N=3
Wn=0.02

Model Graph:

29 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Procedure:

1. Click on the START menu and run the MATLAB Software.


2. A command page appears, now CLICK on the New Script then Editor Window will open.
3. Analyse the problem and design the program and then write the program with prescribed
MATLAB functions and operators.
4. Save the program in “.m” format and click on RUN key.
5. To check the errors in the program, copy the program in Command Window, it checks the
errors if any and give the suggestions to rectify the errors if any.
6. If there are no errors, give the input parameters depending on requirement.
7. Now the OUTPUT waveform will appear on the screen.
8. Observe the Output Waveform.
9. Repeat the same process for different input parameters.

RESULT:

Hence the MATLAB program for frequency response of IIR CHEBYSHEV LPF using
MATLAB functions is verified under different conditions.

30 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Experiment No.-10

FREQUENCY RESPONSE OF IIR HIGH PASS CHEBYSHEV FILTER


Aim: To write a MATLAB Program for frequency response of IIR CHEBYSHEV HPF.

Tools: MATLAB Software


PC
Theory:

1. Chebyshev filters are analog or digital filters having a steeper roll-off and
more passband ripple (type I) or stopband ripple (type II) than Butterworth filters.
2. Chebyshev filters have the property that they minimize the error between the idealized and
the actual filter characteristic over the range of the filter but with ripples in the passband
3. The type I Chebyshev filters are called usually as just "Chebyshev filters", the type II ones
are usually called "inverse Chebyshev filters".
4. Because of the passband ripple inherent in Chebyshev filters, the ones that have a smoother
response in the passband but a more irregular response in the stopband are preferred for
some applications
Program:

(A) CHEBYSHEV TYPE-1

clc;
clear all;
close all;

F=input('enter sampling frequency');


fp=input('enter passband frequency');
fs=input('enter stopband frequency');
rp=input('enter passband ripple');
rs=input('enter stopband ripple');

wp=(2*fp)/F;
ws=(2*fs)/F;

[N,wn]=cheb1ord(wp,ws,rp,rs);

disp('the order of filter is:');disp(N);


disp('the cutoff frequency of filter is:');disp(wn);

[b,a]=cheby1(N,rp,wn, ‘high’);
w=0:0.01:pi;
[h,w1]=freqz(b,a,w);

k=20*log(abs(h));
subplot(2,1,1);plot(w/pi*F/2,k);grid on;
title('magnitude plot'); xlabel('frequency'); ylabel('amplitude');

31 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

g=angle(h);
subplot(2,1,2);plot(w/pi*F/2,g);grid on;title('phase plot');xlabel('frequency');ylabel('angle');

Output:
INPUTS: F=10000
fp=400
fs=1000
rp=4
rs=30

OUTPUTS: N=3
Wn=0.2

Model Graph:

(B) CHEBYSHEV TYPE-2

clc;
clear all;
close all;

F=input('enter sampling frequency');


fp=input('enter passband frequency');
fs=input('enter stopband frequency');
rp=input('enter passband ripple');
rs=input('enter stopband ripple');

wp=(2*fp)/F;

32 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

ws=(2*fs)/F;

[N,wn]=cheb2ord(wp,ws,rp,rs);

disp('the order of filter is:');disp(N);


disp('the cutoff frequency of filter is:');disp(wn);

[b,a]=cheby2(N,rs,wn, ‘high’);
w=0:0.01:pi;
[h,w1]=freqz(b,a,w);

k=20*log(abs(h));
subplot(2,1,1);plot(w/pi*F/2,k);grid on;
title('magnitude plot'); xlabel('frequency'); ylabel('amplitude');

g=angle(h);
subplot(2,1,2);plot(w/pi*F/2,g);grid on;title('phase plot');xlabel('frequency');ylabel('angle');

Output:
INPUTS: F=10000
fp=400
fs=1000
rp=4
rs=30

OUTPUTS: N=3
Wn=0.08

Model Graph:

33 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Procedure:

1. Click on the START menu and run the MATLAB Software.


2. A command page appears, now CLICK on the New Script then Editor Window will open.
3. Analyse the problem and design the program and then write the program with prescribed
MATLAB functions and operators.
4. Save the program in “.m” format and click on RUN key.
5. To check the errors in the program, copy the program in Command Window, it checks the
errors if any and give the suggestions to rectify the errors if any.
6. If there are no errors, give the input parameters depending on requirement.
7. Now the OUTPUT waveform will appear on the screen.
8. Observe the Output Waveform.
9. Repeat the same process for different input parameters.

RESULT:

Hence the MATLAB program for frequency response of IIR CHEBYSHEV HPF using
MATLAB functions is verified under different conditions.

34 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Experiment No.-11

FREQUENCY RESPONSE OF FIR LOW PASS FILTER USING


RECTANGULAR WINDOW
Aim: To write a MATLAB Program for frequency response of FIR LPF using Rectangular
Window.

Tools: MATLAB Software


PC
Theory:

1. In signal processing, a finite impulse response (FIR) filter is a filter whose impulse
response (or response to any finite length input) is of finite duration, because it settles to zero
in finite time. This is in contrast to infinite impulse response (IIR) filters, which may have
internal feedback and may continue to respond indefinitely

2. The impulse response (that is, the output in response to a Kronecker delta input) of an Nth-
order discrete-time FIR filter lasts exactly N + 1 samples (from first nonzero element through
last nonzero element) before it then settles to zero.

3. An FIR filter has a number of useful properties which sometimes make it preferable to
an infinite impulse response (IIR) filter. FIR filters:
a. Require no feedback.
b. Are inherently stable,
c. Can easily be designed to be linear phase by making the coefficient sequence
symmetric. This property is sometimes desired for phase-sensitive applications, for
example data communications, seismology, crossover filters, and mastering.
4. The main disadvantage of FIR filters is that considerably more computation power in a
general purpose processor is required compared to an IIR filter with similar sharpness
or selectivity, especially when low frequency (relative to the sample rate) cutoffs are needed.
However, many digital signal processors provide specialized hardware features to make FIR
filters approximately as efficient as IIR for many applications

Program:

Fs=1000;
Fr=Fs/2;
N=40;
Fc=400/Fr;
b=fir1(N-1,Fc,'low',rectwin(N));
[h,F]=freqz(b,1,512,Fs);
y=20*log(abs(h));
subplot(2,2,1);plot(F,y);grid on;
title('RECTANGULAR WINDOW');
xlabel('Normalized frequency'),ylabel('amplitude');

35 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Model Graph:

Procedure:

1. Click on the START menu and run the MATLAB Software.


2. A command page appears, now CLICK on the New Script then Editor Window will open.
3. Analyse the problem and design the program and then write the program with prescribed
MATLAB functions and operators.
4. Save the program in “.m” format and click on RUN key.
5. To check the errors in the program, copy the program in Command Window, it checks the
errors if any and give the suggestions to rectify the errors if any.
6. If there are no errors, give the input parameters depending on requirement.
7. Now the OUTPUT waveform will appear on the screen.
8. Observe the Output Waveform.
9. Repeat the same process for different input parameters.

RESULT:

Hence the MATLAB program for Program for frequency response of FIR LPF using
Rectangular Window using MATLAB functions is verified under different conditions.

36 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Experiment No.-12

FREQUENCY RESPONSE OF FIR LOW PASS FILTER USING


TRIANGULAR WINDOW
Aim: To write a MATLAB Program for frequency response of FIR LPF using Rectangular
Window.

Tools: MATLAB Software


PC
Theory:

1. In signal processing, a finite impulse response (FIR) filter is a filter whose impulse
response (or response to any finite length input) is of finite duration, because it settles to zero
in finite time. This is in contrast to infinite impulse response (IIR) filters, which may have
internal feedback and may continue to respond indefinitely

2. The impulse response (that is, the output in response to a Kronecker delta input) of an Nth-
order discrete-time FIR filter lasts exactly N + 1 samples (from first nonzero element through
last nonzero element) before it then settles to zero.

3. An FIR filter has a number of useful properties which sometimes make it preferable to
an infinite impulse response (IIR) filter. FIR filters:
a. Require no feedback.
b. Are inherently stable,
c. Can easily be designed to be linear phase by making the coefficient sequence
symmetric. This property is sometimes desired for phase-sensitive applications, for
example data communications, seismology, crossover filters, and mastering.
4. The main disadvantage of FIR filters is that considerably more computation power in a
general purpose processor is required compared to an IIR filter with similar sharpness
or selectivity, especially when low frequency (relative to the sample rate) cutoffs are needed.
However, many digital signal processors provide specialized hardware features to make FIR
filters approximately as efficient as IIR for many applications

Program:

Fs=1000;
Fr=Fs/2;
N=40;
Fc=400/Fr;
b=fir1(N-1,Fc,'low',traing(N));
[h,F]=freqz(b,1,512,Fs);
y=20*log(abs(h));
subplot(2,2,1);plot(F,y);grid on;
title('RECTANGULAR WINDOW');
xlabel('Normalized frequency'),ylabel('amplitude');

37 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Model Graph:

Procedure:

1. Click on the START menu and run the MATLAB Software.


2. A command page appears, now CLICK on the New Script then Editor Window will open.
3. Analyse the problem and design the program and then write the program with prescribed
MATLAB functions and operators.
4. Save the program in “.m” format and click on RUN key.
5. To check the errors in the program, copy the program in Command Window, it checks the
errors if any and give the suggestions to rectify the errors if any.
6. If there are no errors, give the input parameters depending on requirement.
7. Now the OUTPUT waveform will appear on the screen.
8. Observe the Output Waveform.
9. Repeat the same process for different input parameters.

RESULT:

Hence the MATLAB program for Program for frequency response of FIR LPF using
Triangular Window using MATLAB functions is verified under different conditions.

38 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

PART-3
(IMAGE PROCESSING)

Experiment No.-13

False Contouring System

Aim: To write a MATLAB Program to justify false contouring of an image.

Tools: MATLAB Software


PC
Theory:

 Resolution gives the degree of distinguishable detail in an image


 Resolution can be categorised as
o Spatial Resolution
o Gray-level Resolution
 Spatial resolution gives smallest discernible detail in an image. It depends on number of
pixels. Sampling is the principle parameter for describing this.
 Gray-level resolution gives smallest discernible change in gray level. It depends on
number of gray levels.
 The use of insufficient number of gray levels in smooth areas of digital image is called as
False contouring.
Program:
clc
clear all
close all

a=imread('tigerpub.jpg');
imshow(a),title('original image')

%using 128 gray levels


figure,imshow(grayslice(a,128),gray(128)),
title('Image with 128 gray level')

%using 64 gray levels


figure,imshow(grayslice(a,64),gray(64)),
title('Image with 64 gray level')

%using 32 gray levels


figure,imshow(grayslice(a,32),gray(32)),
title('Image with 32 gray level')

%using 16 gray levels


figure,imshow(grayslice(a,16),gray(16)),
title('Image with 16 gray level')

39 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

%using 8 gray levels


figure,imshow(grayslice(a,8),gray(8)),
title('Image with 8 gray level')

Procedure:

1. Click on the START menu and run the MATLAB Software.


2. A command page appears, now CLICK on the New Script then Editor Window will
open.
3. Analyse the problem and design the program and then write the program with prescribed
MATLAB functions and operators.
4. Save the program in “.m” format and click on RUN key.
5. To check the errors in the program, copy the program in Command Window, it checks
the errors if any and give the suggestions to rectify the errors if any.
6. If there are no errors, give the input parameters depending on requirement.
7. Now the OUTPUT waveform will appear on the screen.
8. Observe the Output Waveform.
9. Repeat the same process for different input parameters.

Model graph:

40 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

RESULT:

Hence the false contouring of a digital image is verified under different conditions.

41 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Experiment No.-14

Histogram Equalisation
Aim: To write a MATLAB Program to justify histogram equalisation of an image.

Tools: MATLAB Software


PC
Theory:

 Histogram plots the number of occurrences of gray levels in image against gray-level
values
 It provides a convenient summary of intensities in an image.
 Histogram equalization modifies the histogram of an image so as to improve the visual
quality of an image.
 It attempts to spread out the gray levels in an image so that they are evenly distributed
across their range.
 This reassigns the brightness values of pixels based on Image histogram and provides
more visually pleasing results across a wide range of images.

Program:

clc
clear all
close all

a=imread('babyincradle.png');
%perform histogram equalization
b=histeq(a);

subplot(2,2,1),imshow(a),title('original image'),
subplot(2,2,2),imshow(b),title('After histogram equalization'),
subplot(2,2,3),imhist(a),title('original histogram')
subplot(2,2,4),imhist(b),title('After histogram equalization')

42 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Model Graph:

Procedure:

1. Click on the START menu and run the MATLAB Software.


2. A command page appears, now CLICK on the New Script then Editor Window will
open.
3. Analyse the problem and design the program and then write the program with prescribed
MATLAB functions and operators.
4. Save the program in “.m” format and click on RUN key.
5. To check the errors in the program, copy the program in Command Window, it checks
the errors if any and give the suggestions to rectify the errors if any.
6. If there are no errors, give the input parameters depending on requirement.
7. Now the OUTPUT waveform will appear on the screen.
8. Observe the Output Waveform.
9. Repeat the same process for different input parameters

RESULT:

Hence the histogram equalisation is verified under different conditions.

43 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Experiment No.-15

COMPUTATION OF EDGE OF AN IMAGE USING SPATIAL FILTERS

Aim: To write a MATLAB Program to compute edge of an image.

Tools: MATLAB Software


PC
Theory:

 Edge detection is the process of finding meaningful transitions in an image.


 It is one of the central tasks of the lower levels of Image processing.
 This edge detection algorithms should look for a neighbourhood with strong signs of change.
 The purpose of edge detection is to identify the areas of an image where a large change of
intensity occurs.
 It is going to be performed either by using first order and second order derivatives.

Program:

clc;
clear all;
close all;

a=imread('deer1.jpg');
% a=rgb2gray(a);

b=edge(a,'roberts');
c=edge(a,'sobel');
d=edge(a,'prewitt');
e=edge(a,'log');
f=edge(a,'canny');

subplot(2,3,1);imshow(a); title('original image');


subplot(2,3,2); imshow(b); title('roberts edge detected image');
subplot(2,3,3);imshow(d); title('sobel edge detected image');
subplot(2,3,4);imshow(d); title('prewitt edge detected image');
subplot(2,3,5); imshow(e); title('log edge detected image');
subplot(2,3,6); imshow(f); title('canny edge detected image');

44 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY


DIGITAL SIGNAL PROCESSING LABORATORY 2019-20

Model Graph:

Procedure:

1. Click on the START menu and run the MATLAB Software.


2. A command page appears, now CLICK on the New Script then Editor Window will
open.
3. Analyse the problem and design the program and then write the program with prescribed
MATLAB functions and operators.
4. Save the program in “.m” format and click on RUN key.
5. To check the errors in the program, copy the program in Command Window, it checks
the errors if any and give the suggestions to rectify the errors if any.
6. If there are no errors, give the input parameters depending on requirement.
7. Now the OUTPUT waveform will appear on the screen.
8. Observe the Output Waveform.
9. Repeat the same process for different input parameters

RESULT:

Hence the computation of an image is done by using different edge detection techniques.

45 Dept. of ECE,VIGNAN’S INSTITUTE OF INFORMATION TECHNOLOGY

Вам также может понравиться