# 基于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);


tan_clin

• 擅长领域：
• 嵌入式Linux
• 图像处理
• STM32