Practical 5
Aim : Low pass Average filter and High pass filter used on an image with
Gaussian noise
clear all;
clc;
aa=imread('[Link]');
ab=imnoise(aa,'gaussian'); %Adding noise
q=double(ab);
[row col]=size(q);
w=[1 1 1 ; 1 1 1 ; 1 1 1]/9; %Creating the low pass average mask
v=[-1 -1 -1 ; -1 8 -1 ; -1 -1 -1]; %Creating the high pass average mask
for i=[Link]row-1
for j=[Link]ol-1
q1(i,j) = (w(1) * q(i-1,j-1)) + (w(2) * q(i-1,j)) + (w(3) * q(i1,j+1)) + (w(4) * q(i,j-1)) + (w(5) * q(i,j)) + (w(6) * q(i,j+1)) + (w(7) *
q(i+1,j-1)) + (w(8) * q(i+1,j)) + (w(9) * q(i+1,j+1)) ;
end
end
for i=[Link]row-1
for j=[Link]ol-1
q2(i,j) = (v(1) * q(i-1,j-1)) + (v(2) * q(i-1,j)) + (v(3) * q(i1,j+1)) + (v(4) * q(i,j-1)) + (v(5) * q(i,j)) + (v(6) * q(i,j+1)) + (v(7) *
q(i+1,j-1)) + (v(8) * q(i+1,j)) + (v(9) * q(i+1,j+1)) ;
end
end
subplot(2,2,1),
imshow(uint8(aa));title('Original Image');
subplot(2,2,2);
imshow(uint8(ab));title('Original Image with Gaussian Noise');
subplot(2,2,3);
imshow(uint8(q1));title('Image after using Low Pass Average Filter on
Gaussian Noised image');
subplot(2,2,4);
imshow(uint8(q2));title('Image after using high Pass Average Filter on
Gaussian Noised image');