img = imread('rice.png');
img2 = imnoise(img,'salt & pepper');
subplot(1,3,1);
subimage(img);
title('原图像');
subplot(1,3,2);
subimage(img2);
title('加入噪声的图像');
% 对加入噪声的图像进行处理
[m,n] = size(img);
for i = 2:m-1
for j = 2:n-1
t = img(i-1:i+1,j-1:j+1);
new_img(i,j) = median(t(1:9));
end
end
subplot(1,3,3)
subimage(new_img)
title('中值滤波后的图像');
版权声明:本文为wdf666520原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。