I=imread(1.gif');
J1=imnoise(I,'gaussian',0,0.02);
J2=imnoise(I,'salt & pepper',0.02);
J3=imnoise(I,'speckle',0.02);
运行效果见图2
I=imread('C:/Documents and Settings/Administrator/桌面/1.gif');
J=imnoise(I,'salt & pepper',0.02);
%h=ones(3,3)/9;%产生3*3的全1数组
%B=conv2(J,h);%卷积运算
K2=filter2(fspecial('average',3),J)/255; %均值滤波模板尺寸为3
K= medfilt2(J);%采用二维中值滤波函数medfilt2对受椒盐噪声干扰的图像滤波
K1=wiener2(J,[3 3]); %对加噪图像进行二维自适应维纳滤波
subplot(2,3,1);imshow(I);
title('原始图像');
subplot(2,3,2);imshow(J);
title('加噪图像');
subplot(2,3,3);imshow(K2);
title('均值滤波后的图像');
subplot(2,3,4);imshow(K);
title('中值滤波后的图像');
subplot(2,3,5);imshow(K1);
title('维纳滤波后的图像');