7/29/2019 6015003 Advanced Communications Lab Programs
1/21
M.Tech-II sem (DECS)
Advanced Communications Lab
List of Experiments:
1. Histogram equalization of an image
2. Fourier Transform & its Inverse Fourier Transform of an image
3. Blurring & Deblurring of an image
4. Dilation & Erosion of an image
5. Edge detection (Sobel, canny edge detector) of an image
6. Sampling of an image
7. Frequency Modulation & Demodulation of a signal.
7/29/2019 6015003 Advanced Communications Lab Programs
2/21
MATLAB PROGRAMS
1. Histogram Equalization
Aim: To perform histogram equalization of an image
Equipments:
Operating System: - Windows XP
Software: - Matlab 7.5, Image Processing Toolbox.
Theory:
Program:
clc;
clear all;close all;
f=imread('coins.png');
figure, imshow(f);
title('input image');
h=imhist(f);
h1=h(1:10:256);
horz=1:10:256;
figure, bar(horz,h1);
figure, plot(horz,h1);
title('histogram equalized image');
7/29/2019 6015003 Advanced Communications Lab Programs
3/21
Result:-
7/29/2019 6015003 Advanced Communications Lab Programs
4/21
2. Fourier Transform & Inverse Fourier Transform
Aim: To perform Fourier Transform & its Inverse Fourier Transform of an image
Equipments:
Operating System: - Windows XP
Software: - Matlab 7.5, Image Processing Toolbox.
Theory:
Program:
clc;
clear all;
close all;
A=zeros(30,30);A(5:24,13:17)=1;
subplot(1,2,1);imshow(A);
title('original image');
F=fft2(A);
subplot(1,2,2);imshow(F);
title('fourier transformed image');
S=abs(F)Fc=fftshift(F);
S2=log(1+abs(Fc));
figure,subplot(1,2,1);
imshow(Fc);
title('fourier transformed image');
F=ifftshift(Fc)
f1=(ifft2(F));
subplot(1,2,2);
imshow(f1);
title('inverse transform');
7/29/2019 6015003 Advanced Communications Lab Programs
5/21
Result :-
7/29/2019 6015003 Advanced Communications Lab Programs
6/21
7/29/2019 6015003 Advanced Communications Lab Programs
7/21
3. Blurring & Deblurring
Aim: To perform blurring & deblurring of an image
Equipments:
Operating System: - Windows XP
Software: - Matlab 7.5, Image Processing Toolbox.
Theory:
Program:
clc;
close all;
clear all;f=imread('cameraman.tif');
subplot(1,2,1);imshow(f);title('original image');
LEN = 31;THETA = 11;
PSF = fspecial('motion',LEN,THETA);
Blurred = imfilter(f,PSF,'circular','conv');
subplot(1,2,2);imshow(Blurred);title('Blurred Image');% deblurring
figure,subplot(1,2,1);imshow(Blurred);title('Blurred image');
wnr1 = deconvwnr(Blurred,PSF);
subplot(1,2,2);imshow(wnr1);title('Deblurred Image');
title('Restored, True PSF');
7/29/2019 6015003 Advanced Communications Lab Programs
8/21
Result:-
7/29/2019 6015003 Advanced Communications Lab Programs
9/21
7/29/2019 6015003 Advanced Communications Lab Programs
10/21
4. Dilation & ErosionAim: To perform dilation & erosion of an image
Equipments:
Operating System: - Windows XPSoftware: - Matlab 7.5, Image Processing Toolbox.
Theory:
Program:
close all;
clear all;
clc;
f=imread('cameraman.tif');
level=graythresh(f);f1=im2bw(f,level);
s=[0 1 0; 1 1 1 ; 0 1 0];
f2=imdilate(f1,s);
subplot(1,3,1);imshow(f);title('original image');subplot(1,3,2);imshow(f1);title('binary image');
subplot(1,3,3);imshow(f2);title('dilated image');
7/29/2019 6015003 Advanced Communications Lab Programs
11/21
Result:-
7/29/2019 6015003 Advanced Communications Lab Programs
12/21
7/29/2019 6015003 Advanced Communications Lab Programs
13/21
5. Edge Detection
Aim: To perform edge detection of an image
Equipments:
Operating System: - Windows XP
Software: - Matlab 7.5, Image Processing Toolbox.
Theory:
Program:
clc;0000
close all;
clear all;
f=imread('trees.tif');subplot(1,2,1);
imshow(f);title('original image');
BW1=edge(f,'sobel');
BW2=edge(f,'canny');
subplot(1,2,2);
imshow(BW1);title('sobel edge detector image');
figure,subplot(1,2,1);imshow(f);title('original image');
subplot(1,2,2);
imshow(BW2);title('canny edge detector image');
7/29/2019 6015003 Advanced Communications Lab Programs
14/21
Result:-
7/29/2019 6015003 Advanced Communications Lab Programs
15/21
7/29/2019 6015003 Advanced Communications Lab Programs
16/21
6. Sampling
Aim: To perform sampling of an image
Equipments:
Operating System :- Windows XP
Software:- Matlab 7.5, Image Processing Toolbox.
Theory:
Program:
if (nargin==0)
hFig = figure( 'visible','off' );
hImage = image;
Child = get( hImage,'cdata' );close( hFig );
out = updownsample( Child,300,300,0,1 );
figure;
colormap gray;
subplot( 1,2,1 );
imagesc( Child );
subplot( 1,2,2 );
imagesc( out );
return
elseif (nargin do not change sampling rate
if is_fourier_flag
switch is_real_flag
case 0, out_m = ifft2( in_m );
case 1, out_m = real( ifft2( in_m ) );
case 2, out_m = abs( ifft2( in_m ) );end
else
out_m = in_m;
end
else
% upsample or downsample as needed
% convert to fourier domain, if input is given in the space domain
if ~is_fourier_flag
7/29/2019 6015003 Advanced Communications Lab Programs
17/21
in_m = fft2(in_m);
end
% if the input is even & output is odd-> use floor for all
% if the output is even & input is odd -> use ceil for all
% for downsampling -> the oppositeif (~mod( in_x_sz,2 ) & (out_x_sz>in_x_sz)) | (mod( in_x_sz,2 ) & (out_x_szin_y_sz)) | (mod( in_y_sz,2 ) & (out_y_sz
7/29/2019 6015003 Advanced Communications Lab Programs
18/21
Result:-
7/29/2019 6015003 Advanced Communications Lab Programs
19/21
7. Frequency Modulation & Demodulation
Aim: To perform Frequency Modulation & Demodulation of a signal
Equipments:
Operating System: - Windows XP
Software: - Matlab 7.5, Image Processing Toolbox.
Theory:
Program:
Fs = 8000; % Sampling rate of signal
Fc = 3000; % Carrier frequency
t = [0:Fs]/Fs; % Sampling timess1 = sin(2*pi*10*t); % Channel 1
%s2 = sin(2*pi*150*t)+2*sin(2*pi*900*t); % Channel 2
%x = [s1]; % Two-channel signaldev = 50; % Frequency deviation in modulated signal
y = fmmod(s1,Fc,Fs,dev); % Modulate both channels.
z = fmdemod(y,Fc,Fs,dev); % Demodulate both channels.
subplot(2,1,1); plot(t,y); title('frequency modulated image');% Plot x on top.subplot(2,1,2); plot(t,z);title('demodulated image');% Plot y below.
7/29/2019 6015003 Advanced Communications Lab Programs
20/21
Result:-
7/29/2019 6015003 Advanced Communications Lab Programs
21/21