对加入椒盐噪声的图像分别作均值、中值和维纳滤波

function FuShiPengZhang
%I=imread('C:\Users\user\Desktop\data\Gabor-1-120\2-1.jpg'); 
%J1=imnoise(I,'gaussian',0,0.02); 
%J2=imnoise(I,'salt & pepper',0.02); 
%J3=imnoise(I,'speckle',0.02); 
%运行效果见图2 
I=imread('H:\360data\重要数据\我的图片\h_large_WiMa_5f3e00039d602f75.jpg'); 
I = rgb2gray(I);
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('维纳滤波后的图像'); 
end

你可能感兴趣的:(c,function,filter,user,360)