n=15
比较结果:
n值越大,图片纹理越清晰。 4.
(1)代码:
f=imread('C:\\Documents and Settings\\student\\×à??\\test4\\ckt-board.tif'); fn=imnoise(f,'salt & pepper',0.2); gm=medfilt2(fn);
gms=medfilt2(fn,'symmetric');
subplot(2,2,1) imshow(f); title('a');
subplot(2,2,2) imshow(fn); title('b');
subplot(2,2,3) imshow(gm); title('c');
subplot(2,2,4) imshow(gms); title('d');
-6-
实验结果:
(2)代码:n=3
f=imread('C:\\Users\\Administrator\\Desktop\\学习\\数字图像处理\\实验四\\test4\\ckt-board.tif'); g1=ordfilt2(f,1,ones(n));
g2=ordfilt2(f,(n+1)/2,ones(n));
g3=ordfilt2(f,n,ones(n));
subplot(1,3,1); imshow(g1); title('a');
subplot(1,3,2); imshow(g2); title('b');
subplot(1,3,3); imshow(g3); title('c');
实验结果:
-7-
比较:经过中值滤波后的图像既适合人眼的视觉感觉又能够消除图像中的干扰影响。可以看到中值滤波对于滤除图像的“椒盐”噪声非常有效,它可以做到既去除噪声又能保护图像的边缘,从而获得较满意的复原效果,尤其在滤除叠加白噪声和长尾叠加噪声方面显出极好的性能。而采用最大值滤波方式,发现它对椒噪声有效,善于发现图像中的亮点。最小值滤波的方式,发现它对盐噪声有效,善于发现图像中的暗点。
-8-