Professional Documents
Culture Documents
Assignment No.2: Advance Power Protection
Assignment No.2: Advance Power Protection
REG.NO: 16062244-009
DATE: 06-05-2017
Spatial filtering
Correlation
f=[0 0 0 1 0 0 0 0];
w=[1 2 3 2 8];
g=imfilter(f,w,'corr',0,'full')
g=
0 0 0 8 2 3 2 1 0 0 0 0
f=imread('figg.TIF');
subplot(2,1,1);
imshow(f);
w=ones(31);
gd=imfilter(f,w);
subplot(2,1,2);
imshow(gd,[]);
Convolution
g=imfilter(f,w,'conv','replicate')
0 0 0 0 0
0 1 2 3 0
0 4 5 6 0
0 7 8 9 0
0 0 0 0 0
Nonlinear spatial filter
output
1 2 2 2
3 4 4 4
3 4 4 4
3 4 4 4
3 4 4 4
Median filter
f=imread('fig01.TIF');
subplot(2,1,1);
imshow(f);
title('orginal image');
fn=imnoise(f,'salt & pepper',0.2);
gm=medfilt2(fn);
subplot(2,1,2);
imshow(gm);
Laplacian filter
I=imread('moon.PNG');
subplot(2,2,1);
imshow(I);
w4=fspecial('laplacian',0);
w8=[1 1 1;1 -8 1;1 1 1];
f=im2double(I);
g4=f-imfilter(f,w4,'replicate');
g8=f-imfilter(f,w8,'replicate');
subplot(2,2,2);
imshow(g4);
subplot(2,2,3);
imshow(g8);
Gaussian filter
f=imread('guss.TIF');
subplot(2,2,1);
imshow(f);
title('orignal image');
a=imnoise(f,'gaussian',0.01);
subplot(2,2,2);
imshow(a);
title('noised image');
sigma=3;
cutoff=ceil(3*sigma);
h=fspecial('gaussian',2*cutoff+1,sigma);
out=conv2(f,h,'same');
subplot(2,2,3);
imshow(out/256);
title('final image');