基于matlab的数字图像处理---图像滤波(高斯噪声、椒盐噪声,高斯滤波、中值滤波)

对图像进行添加高斯噪声、椒盐噪声处理之后,使用高斯滤波、中值滤波方式对添加噪声的图像进行滤波处理,实现程序如下:

clc
P = imread('原始图像.jpg'); % 读入图像
figure
img=rgb2gray(P);
imwrite(img,'甲.png');
imshow(img)
title('原始图像')

img1=imnoise(img,'salt & pepper',0.05);
figure
imshow(img1)
title('椒盐噪声 参数:0.05')

img2=imnoise(img,'gaussian',0.01);
figure
imshow(img2)
title('高斯噪声 参数:0.01')

H1=fspecial('gaussian', [3,3], 1);  
img_gauss1=imfilter(img1,H1,'replicate'); 
figure
imshow(img_gauss1)
title('椒盐噪声-高斯滤波')

img_median1=medfilt2(img1,[3 3]);
figure
imshow(img_median1)
title('椒盐噪声-中值滤波')

H2=fspecial('gaussian', [3,3], 1);  
img_gauss2=imfilter(img2,H2,'replicate'); 
figure
imshow(img_gauss2)
title('高斯噪声-高斯滤波')

img_median2=medfilt2(img2,[3 3]);
figure
imshow(img_median2)
title('高斯噪声-中值滤波')

a=abs(img_gauss1-img);
data1=mean(a(:));
fprintf('乙G -甲 =%f\n',data1);

b=abs(img_gauss2-img);
data2=mean(b(:));
fprintf('丙G -甲 =%f\n',data2);

c=abs(img_median1-img);
data3=mean(c(:));
fprintf('乙M -甲 =%f\n',data3);

d=abs(img_median2-img);
data4=mean(d(:));
fprintf('丙M -甲 =%f\n',data4);

你可能感兴趣的:(数字图像处理)