Exp 7 - Exp 11.docx
Exp 7 - Exp 11.docx
Exp 7 - Exp 11.docx
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.
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