## EbowTang的练习场

1,新手需要努力,高手更需要努力。2,性格大于能力。3，解决问题的能力决定未来。...

# 二，噪声测试效果

## 2，实验代码

<span style="font-size:12px;">%读入原始图像并显示
figure(1)
subplot(2,4,1);
imshow(image_original);
title('原输入图像');
axis square;

%生成含高斯噪声图像并显示
pp=0.05;
image_gaosi_noise=imnoise(image_original,'gaussian',0,pp);
subplot(2,4,2);
imshow(image_gaosi_noise);
title('添加高斯噪声后图像');
axis square;

%生成含椒盐噪声图像并显示
d=0.05;
image_saltpepper_noise=imnoise(image_original,'salt & pepper',d);
subplot(2,4,3);
imshow(image_saltpepper_noise);
title('添加椒盐噪声后图像');
axis square;

%生成含乘性噪声图像并显示
var=0.05;
image_speckle_noise=imnoise(image_original,'speckle',var);
subplot(2,4,4);
imshow(image_speckle_noise);
title('添加乘性噪声后图像');
axis square;

%原图像直方图
r=0:255;
bb=image_original(:);
pg=hist(bb,r);
pgr1=pg/length(bb);
subplot(245);bar(pgr1);title('源输入图像的直方图');

r=0:255;
bl=image_gaosi_noise(:);
pg=hist(bl,r);
pgr2=pg/length(bl);
subplot(246);bar(pgr2);title('高斯噪声污染后的直方图');

r=0:255;
bh=image_saltpepper_noise(:);
pu=hist(bh,r);
pgr3=pu/length(bh);
subplot(247);bar(pgr3);title('椒盐噪声污染后的直方图');

r=0:255;
ba=image_speckle_noise(:);
pa=hist(ba,r);
pgr4=pa/length(ba);
subplot(248);bar(pgr4);title('乘性噪声污染后直方图');</span>

# 三，椒盐噪声去除能力对比

## 2，实现代码

<span style="font-size:12px;"></span><pre name="code" class="cpp">%读入原始图像并显示
figure(1)
subplot(2,4,1);
imshow(image_original);
title('原输入图像');
axis square;

%生成含高斯噪声图像并显示
%pp=0.05;
%image_gaosi_noise=imnoise(image_original,'gaussian',0,pp);

%生成含椒盐噪声图像并显示
dd=0.05;
image_saltpepper_noise=imnoise(image_original,'salt & pepper',dd);

%生成含乘性噪声图像并显示
%var=0.05;
%image_speckle_noise=imnoise(image_original,'speckle',var);

image_saltpepper_noise_after1=medfilt2(image_saltpepper_noise,[3,3]);
subplot(2,4,2);
imshow(image_saltpepper_noise_after1);title('中值滤波去椒盐噪声效果图');
axis square;

h_gaosi1=fspecial('gaussian',3,1);
image_saltpepper_noise_after2=imfilter(image_saltpepper_noise,h_gaosi1);
subplot(2,4,3);
imshow(image_saltpepper_noise_after2);title('高斯平滑去椒盐噪声效果');
axis square;

image_saltpepper_noise_after3=wiener2(image_saltpepper_noise,[5 5]);
subplot(2,4,4);
imshow(image_saltpepper_noise_after3);title('维纳滤波去椒盐噪声效果');
axis square;

%原图像直方图
r=0:255;
bb=image_original(:);
pg=hist(bb,r);
pgr1=pg/length(bb);
subplot(245);bar(pgr1);title('源输入图像的直方图');

r=0:255;
bl=image_saltpepper_noise_after1(:);
pg=hist(bl,r);
pgr2=pg/length(bl);
subplot(246);bar(pgr2);title('中值滤波去椒盐噪声后的直方图');

r=0:255;
bh=image_saltpepper_noise_after2(:);
pu=hist(bh,r);
pgr3=pu/length(bh);
subplot(247);bar(pgr3);title('高斯平滑去椒盐噪声后的直方图');

r=0:255;
ba=image_saltpepper_noise_after3(:);
pa=hist(ba,r);
pgr4=pa/length(ba);
subplot(248);bar(pgr4);title('维纳滤波去除椒盐噪声后的直方图');

# 四，高斯噪声去除能力对比

## 2，实验代码

<span style="font-size:12px;"></span><pre name="code" class="cpp">%读入原始图像并显示
figure(1)
subplot(2,4,1);
imshow(image_original);
title('原输入图像');
axis square;

%生成含高斯噪声图像并显示
pp=0.05;
image_gaosi_noise=imnoise(image_original,'gaussian',0,pp);

%生成含椒盐噪声图像并显示
%dd=0.01;
%image_saltpepper_noise=imnoise(image_original,'salt & pepper',dd);

%生成含乘性噪声图像并显示
%var=0.05;
%image_speckle_noise=imnoise(image_original,'speckle',var);

image_gaosi_noise_after1=medfilt2(image_gaosi_noise,[3,3]);
subplot(2,4,2);
imshow(image_gaosi_noise_after1);title('中值滤波去高斯噪声效果图');
axis square;

h_gaosi1=fspecial('gaussian',3,1);
image_gaosi_noise_after2=imfilter(image_gaosi_noise,h_gaosi1);
subplot(2,4,3);
imshow(image_gaosi_noise_after2);title('高斯平滑去高斯噪声效果');
axis square;

image_gaosi_noise_after3=wiener2(image_gaosi_noise,[5 5]);
subplot(2,4,4);
imshow(image_gaosi_noise_after3);title('维纳滤波去高斯噪声效果');
axis square;

%原图像直方图
r=0:255;
bb=image_original(:);
pg=hist(bb,r);
pgr1=pg/length(bb);
subplot(245);bar(pgr1);title('源输入图像的直方图');

r=0:255;
bl=image_gaosi_noise_after1(:);
pg=hist(bl,r);
pgr2=pg/length(bl);
subplot(246);bar(pgr2);title('中值滤波去高斯噪声后的直方图');

r=0:255;
bh=image_gaosi_noise_after2(:);
pu=hist(bh,r);
pgr3=pu/length(bh);
subplot(247);bar(pgr3);title('高斯平滑去高斯噪声后的直方图');

r=0:255;
ba=image_gaosi_noise_after3(:);
pa=hist(ba,r);
pgr4=pa/length(ba);
subplot(248);bar(pgr4);title('维纳滤波去除高斯噪声后的直方图');

# 五，乘性噪声去除能力对比

## 2，实验代码

<span style="font-size:12px;">%读入原始图像并显示
figure(1)
subplot(2,4,1);
imshow(image_original);
title('原输入图像');
axis square;

%生成含高斯噪声图像并显示
%pp=0.01;
%image_gaosi_noise=imnoise(image_original,'gaussian',0,pp);

%生成含椒盐噪声图像并显示
%dd=0.01;
%image_saltpepper_noise=imnoise(image_original,'salt & pepper',dd);

%生成含乘性噪声图像并显示
var=0.01;
image_speckle_noise=imnoise(image_original,'speckle',var);

image_speckle_noise_after1=medfilt2(image_speckle_noise,[3,3]);
subplot(2,4,2);
imshow(image_speckle_noise_after1);title('中值滤波去乘性噪声效果图');
axis square;

h_gaosi1=fspecial('gaussian',3,1);
image_speckle_noise_after2=imfilter(image_speckle_noise,h_gaosi1);
subplot(2,4,3);
imshow(image_speckle_noise_after2);title('高斯平滑去乘性噪声效果');
axis square;

image_speckle_noise_after3=wiener2(image_speckle_noise,[5 5]);
subplot(2,4,4);
imshow(image_speckle_noise_after3);title('维纳滤波去乘性噪声效果');
axis square;

%原图像直方图
r=0:255;
bb=image_original(:);
pg=hist(bb,r);
pgr1=pg/length(bb);
subplot(245);bar(pgr1);title('源输入图像的直方图');

r=0:255;
bl=image_speckle_noise_after1(:);
pg=hist(bl,r);
pgr2=pg/length(bl);
subplot(246);bar(pgr2);title('中值滤波去乘性噪声后的直方图');

r=0:255;
bh=image_speckle_noise_after2(:);
pu=hist(bh,r);
pgr3=pu/length(bh);
subplot(247);bar(pgr3);title('高斯平滑去乘性噪声后的直方图');

r=0:255;
ba=image_speckle_noise_after3(:);
pa=hist(ba,r);
pgr4=pa/length(ba);
subplot(248);bar(pgr4);title('维纳滤波去除乘性噪声后的直方图');</span>

（PNSR客观对比越高越好）

# 参考资源

【1】《百度百科》

【2】《维基百科》

【3】冈萨雷斯《数字图像处理》

【4】http://blog.csdn.net/ebowtang/article/details/38960271

#### 小波图像去噪及matlab实例

2017-03-09 15:09:48

#### 七种滤波方法的matlab实现和测试

2016-10-17 17:09:03

#### 维纳滤波消噪算法MATLAB源程序

2016年01月04日 37KB 下载

#### 数字图像去噪典型算法及matlab实现

2015-05-13 20:47:44

#### 音频噪声抑制（2）：维纳（Wiener）滤波器篇

2016-12-03 20:07:51

#### 【Matlab学习笔记】【图像滤波去噪】高斯平滑滤波

2015-05-13 08:05:42

#### matlab三大低通滤波器的简单使用

2017-04-19 15:41:45

#### 关于高斯滤波的一些理解

2017-01-04 07:44:34

#### 基于高斯滤波去噪方法

2010年05月23日 437B 下载

#### 高斯滤波

2016-02-04 14:49:35