advanced communications lab programs

22
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.

Upload: chanukya-krishna-chama

Post on 11-Apr-2015

1.758 views

Category:

Documents


1 download

DESCRIPTION

M.Tech (DECS)1st yr 2nd sem ADVANCED COMMUNICATIONS LAB MANUAL

TRANSCRIPT

Page 1: Advanced Communications Lab Programs

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.

Page 2: Advanced Communications Lab Programs

MATLAB PROGRAMS

1. Histogram Equalization

Aim: To perform histogram equalization of an image

Equipments:

Operating System: - Windows XPSoftware: - 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');

Page 3: Advanced Communications Lab Programs

Result:-

Page 4: Advanced Communications Lab Programs

2. Fourier Transform & Inverse Fourier Transform

Aim: To perform Fourier Transform & its Inverse Fourier Transform of an image

Equipments:

Operating System: - Windows XPSoftware: - 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');

Page 5: Advanced Communications Lab Programs

Result :-

Page 6: Advanced Communications Lab Programs
Page 7: Advanced Communications Lab Programs

3. Blurring & Deblurring

Aim: To perform blurring & deblurring of an image

Equipments:

Operating System: - Windows XPSoftware: - 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');% deblurringfigure,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');

Page 8: Advanced Communications Lab Programs

Result:-

Page 9: Advanced Communications Lab Programs
Page 10: Advanced Communications Lab Programs

4. Dilation & Erosion Aim: 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');

Page 11: Advanced Communications Lab Programs

Result:-

Page 12: Advanced Communications Lab Programs
Page 13: Advanced Communications Lab Programs

5. Edge Detection

Aim: To perform edge detection of an image

Equipments:

Operating System: - Windows XPSoftware: - Matlab 7.5, Image Processing Toolbox.

Theory:

Program:

clc;0000close 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');

Page 14: Advanced Communications Lab Programs

Result:-

Page 15: Advanced Communications Lab Programs
Page 16: Advanced Communications Lab Programs

6. Sampling

Aim: To perform sampling of an image

Equipments:

Operating System :- Windows XPSoftware:- 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 );

returnelseif (nargin<5) error( 'UpDownSample - insufficient input parameters' );end% get input image size, and calculate the gain[in_y_sz,in_x_sz] = size( in_m );gain_x = out_x_sz/in_x_sz;gain_y = out_y_sz/in_y_sz;% check if up/down sampling is needed at allif (gain_x == 1) & (gain_y==1) % same gain -> 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; endelse % upsample or downsample as needed % convert to fourier domain, if input is given in the space domain if ~is_fourier_flag

Page 17: Advanced Communications Lab Programs

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 opposite if (~mod( in_x_sz,2 ) & (out_x_sz>in_x_sz)) | (mod( in_x_sz,2 ) & (out_x_sz<in_x_sz)) x_output_space = max(floor((out_x_sz-in_x_sz)/2),0) + [1:min(in_x_sz,out_x_sz)]; x_input_space = max(floor((in_x_sz-out_x_sz)/2),0) + [1:min(in_x_sz,out_x_sz)]; else x_output_space = max(ceil((out_x_sz-in_x_sz)/2),0) + [1:min(in_x_sz,out_x_sz)]; x_input_space = max(ceil((in_x_sz-out_x_sz)/2),0) + [1:min(in_x_sz,out_x_sz)]; end if (~mod( in_y_sz,2 ) & (out_y_sz>in_y_sz)) | (mod( in_y_sz,2 ) & (out_y_sz<in_y_sz)) y_output_space = max(floor((out_y_sz-in_y_sz)/2),0) + [1:min(in_y_sz,out_y_sz)]; y_input_space = max(floor((in_y_sz-out_y_sz)/2),0) + [1:min(in_y_sz,out_y_sz)]; else y_output_space = max(ceil((out_y_sz-in_y_sz)/2),0) + [1:min(in_y_sz,out_y_sz)]; y_input_space = max(ceil((in_y_sz-out_y_sz)/2),0) + [1:min(in_y_sz,out_y_sz)]; end % perform the up/down sampling padded_out_m = zeros( out_y_sz,out_x_sz ); in_m = fftshift(in_m); padded_out_m( y_output_space,x_output_space ) = in_m(y_input_space,x_input_space); out_m = (gain_x*gain_y)*ifft2(ifftshift(padded_out_m)); switch is_real_flag case 0, % do nothing case 1, out_m = real( out_m ); case 2, out_m = abs( out_m ); end end

Page 18: Advanced Communications Lab Programs

Result:-

Page 19: Advanced Communications Lab Programs

7. Frequency Modulation & Demodulation

Aim: To perform Frequency Modulation & Demodulation of a signal

Equipments:

Operating System: - Windows XPSoftware: - Matlab 7.5, Image Processing Toolbox.

Theory:

Program:

Fs = 8000; % Sampling rate of signalFc = 3000; % Carrier frequencyt = [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 signaly = 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.

Page 20: Advanced Communications Lab Programs

Result:-

Page 21: Advanced Communications Lab Programs