0% found this document useful (0 votes)
29 views8 pages

Assignment No.2: Advance Power Protection

This document discusses various spatial filtering techniques in image processing including correlation filtering, convolution, nonlinear spatial filtering, median filtering, Laplacian filtering, and Gaussian filtering. Code examples are provided to demonstrate how to apply each of these filtering methods using the MATLAB image processing toolbox. Key spatial filtering concepts and functions like imfilter, fspecial, medfilt2, and conv2 are introduced.

Uploaded by

Ajmal Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views8 pages

Assignment No.2: Advance Power Protection

This document discusses various spatial filtering techniques in image processing including correlation filtering, convolution, nonlinear spatial filtering, median filtering, Laplacian filtering, and Gaussian filtering. Code examples are provided to demonstrate how to apply each of these filtering methods using the MATLAB image processing toolbox. Key spatial filtering concepts and functions like imfilter, fspecial, medfilt2, and conv2 are introduced.

Uploaded by

Ajmal Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

ASSIGNMENT NO.

SUBJECT: ADVANCE POWER PROTECTION

Submitted By: RANA FARAN AHMED

REG.NO: 16062244-009

Submitted To: Sir.Nazim

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

f=[0 0 0 0 0 ; 0 0 0 0 0 ; 0 0 1 0 0; 0 0 0 0 0;0 0 0 0 0];

w=[1 2 3;4 5 6;7 8 9];

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

f=[1 2;3 4];


fp=padarray(f,[3 2],'replicate' ,'post')

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');

You might also like