Lenna = imread('lenna2.jpg');
NoiseLenna =
imnoise(Lenna,'salt & pepper',0.02);
GF1 = fspecial('gaussian',[3
3],0.5);
GF2 = fspecial('gaussian',[5
5],0.5);
GF3 = fspecial('gaussian',[7
7],0.5);
AV1 = [1 1 1;
1 1 1;
1 1 1]/9;
AV2 = [1 1 1 1 1;
1 1 1 1 1;
1 1 1 1 1;
1 1 1 1 1;
1 1 1 1 1]/25;
AV3 = [1 1 1 1 1 1 1;
1 1 1 1 1 1 1;
1 1 1 1 1 1 1;
1 1 1 1 1 1 1;
1 1 1 1 1 1 1;
1 1 1 1 1 1 1;
1 1 1 1 1 1 1]/49;
GaussLenna =
imfilter(NoiseLenna,GF1);
subplot(3,4,1); imshow(GaussLenna); ylabel('3x3'); title('Gaussian Filter');
GaussLenna = imfilter(NoiseLenna,GF2);
subplot(3,4,5); imshow(GaussLenna); ylabel('5x5');
GaussLenna =
imfilter(NoiseLenna,GF3);
subplot(3,4,9); imshow(GaussLenna); ylabel('7x7');
AvgLenna =
imfilter(NoiseLenna,AV1);
subplot(3,4,2); imshow(AvgLenna); title('Averaging Filter');
AvgLenna =
imfilter(NoiseLenna,AV2);
subplot(3,4,6); imshow(AvgLenna);
AvgLenna =
imfilter(NoiseLenna,AV3);
subplot(3,4,10); imshow(AvgLenna);
MedLenna =
medfilt2(NoiseLenna,[3 3]);
subplot(3,4,3); imshow(MedLenna); title('Median Filter');
MedLenna =
medfilt2(NoiseLenna,[5 5]);
subplot(3,4,7); imshow(MedLenna);
MedLenna =
medfilt2(NoiseLenna,[7 7]);
subplot(3,4,11); imshow(MedLenna);
OrdLenna =
ordfilt2(NoiseLenna,5,ones(3,3));
subplot(3,4,4); imshow(OrdLenna); title('Ordered Filter');
OrdLenna =
ordfilt2(NoiseLenna,5,ones(5,5));
subplot(3,4,8); imshow(OrdLenna);
OrdLenna =
ordfilt2(NoiseLenna,5,ones(7,7));
subplot(3,4,12); imshow(OrdLenna);
No comments:
Post a Comment