Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Exp 7 - Exp 11.docx

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Exp.

7
To Implement smoothing or averaging filter in spatial domain.

PROGRAM:
% Program for implementation of smoothing or averaging filter in spatial domain
I=imread('trees.tif');
subplot(2,2,1);
imshow(J);
title('original image');
f=ones(3,3)/9;
h=imfilter(I,f,'circular');
subplot(2,2,2);
imshow(h);
title('averaged image');

Exp. 8
To find neighbour of a given pixel.

% To find Neighbour of a given Pixel


a=magic(5);
disp(‘a=’); disp(a);
b=input('Enter the row < size of the Matrix');
c=input(' Enter the Column < size of matrix');
disp(‘Element’); disp(a(b,c));
% 4 Point Neighbour
N4=[a(b+1,c), a(b-1,c), a(b,c+1), a(b,c-1)];
disp(‘N4=’); disp(N4);
%8 Point Neighbour
N8=[a(b+1,c), a(b-1,c), a(b,c+1), a(b,c-1), a(b+1,c+1), a(b+1,c-1), a(b-1,c-1), a(b-1,c+1)];
disp(‘N8=’); disp(N8);
%Diagonal Neighbour
ND=[ a(b+1,c+1), a(b+1,c-1), a(b-1,c-1), a(b-1,c+1)];
disp(‘ND=’); disp(ND);

Exp. 9
Program for morphological operation: erosion and dilation.

PROGRAM:
% Program for morphological operations: Erosions& Dilation
f=imread('coins.png');
B=[0 1 1;1 1 1;0 1 0];
f1=imdilate(f,B);
se=strel('disk',10);
f2=imerode(f,se);
figure,imshow(f)
title('input image');
figure,imshow(f1)
title('delated image');
figure,imshow(f2)
title('eroded image');

Exp. 10
Program of sharpen image using gradient mask.

PROGRAM:
% Program of sharpen image using gradient mask
I=imread('coins.png');
subplot(2,2,1);
imshow(I)
title('Original Image');
h=fspecial('sobel');
f=imfilter(I,h,'replicate');
subplot(2,2,2);
imshow(F)
title('filtered image by sobel mask');
s=I+F;
subplot(2,2,4);
imshow(s)
title('Final o/p Image');

Exp. 11
Program for DCT/IDCT computation.

PROGRAM:
clc;
clear all;
close all;
m=input('Enter the basis matrix dimension: '); % Request user input
n=m;
alpha2=ones(1,n)*sqrt(2/n);
alpha2(1)=sqrt(1/n);
alpha1=ones(1,m)*sqrt(2/m);
alpha(1)=sqrt(1/m); % square root.
for u=0:m-1
for v=0:n-1
for x=0:m-1
for y=0:n-1
a{u+1,v+1}(x+1,y+1)=alpha1(u+1)*alpha2(v+1)*...
cos((2*x+1)*u*pi/(2*n))*cos((2*y+1)*v*pi/(2*n));
end
end
end
end
mag=a;
figure(3) % Create figure graphics object
k=1;
% Code to plot the basis
for i=1:m
for j=1:n
subplot(m,n,k)
imshow(mag{i,j},256)
k=k+1;
end
end

You might also like