Spatial Filtering involves passing a weighted mask over the image and replacing the original pixel value corresponding to the center of the mask .
The size of the mask should be odd to ensure it has a center value .
Matlab Code for Average filter
a=imread(‘cameraman.tif’);
h1=(1/9)*ones(3,3);
h2=(1/25)*ones(5,5);
b1=conv2(a,h1,’same’);
b2=conv2(a,h2,’same’);
figure
imshow(uint8(b1));
title(‘output image using 3×3 mask’);
figure
imshow(uint8(b2));
The size of the mask should be odd to ensure it has a center value .
Matlab Code for Average filter
a=imread(‘cameraman.tif’);
h1=(1/9)*ones(3,3);
h2=(1/25)*ones(5,5);
b1=conv2(a,h1,’same’);
b2=conv2(a,h2,’same’);
figure
imshow(uint8(b1));
title(‘output image using 3×3 mask’);
figure
imshow(uint8(b2));
Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com