【数字图像处理】灰度图像中添加高斯噪声、椒盐噪声、斑点噪声以及利用不同方法(中值、排序、维纳滤波)去除各种噪声的matlab程序

图像处理问题描述:

1、图像中分别加入不同方差的高斯噪声、不同噪声密度椒盐噪声和不同方差的斑点噪声(Gaussian noise, salt & pepper noise and speckle noise)
2、分别通过函数medfilt2、ordfilt2和 Wiener 2 去除图像中添加的一些噪声(Gaussian noise, salt & pepper noise and speckle noise)。

各部分程序代码如下:

%Part 1
%Gaussian noise
g=imread('cameraman.tif');
h=imnoise(g,'gaussian',0.05,0.1);
h1=imnoise(g,'gaussian',0.1,0.1);
h2=imnoise(g,'gaussian',0.05,0.2);
subplot(1,4,1),imshow(g);
subplot(1,4,2),imshow(h);
subplot(1,4,3),imshow(h1);
subplot(1,4,4),imshow(h2);
%Salt & pepper noise
g=imread('cameraman.tif');
h=imnoise(g,'salt & pepper',0.05);
h1=imnoise(g,'salt & pepper',0.1);
h2=imnoise(g,'salt & pepper',0.2);
subplot(1,4,1),imshow(g);
subplot(1,4,2),imshow(h);
subplot(1,4,3),imshow(h1);
subplot(1,4,4),imshow(h2);
%Speckle noise
g=imread('cameraman.tif');
h=imnoise(g,'speckle',0.05);
h1=imnoise(g,'speckle',0.2);
subplot(1,3,1),imshow(g);
subplot(1,3,2),imshow(h);
subplot(1,3,3),imshow(h1);
%Part 2
%Removing gaussian noise
g=imread('cameraman.tif');
h=imnoise(g,'gaussian',0.03,0.05);
h1=medfilt2(h,[5,5]);
h2=ordfilt2(h,25,ones(5,5));
h3=wiener2(h,[5,5]);
subplot(1,5,1),imshow(g);
subplot(1,5,2),imshow(h);
subplot(1,5,3),imshow(h1);
subplot(1,5,4),imshow(h2);
subplot(1,5,5),imshow(h3);
%Removing salt & pepper noise
g=imread('cameraman.tif');
h=imnoise(g,'salt & pepper',0.15);
h1=medfilt2(h,[5,5]);
h2=ordfilt2(h,25,ones(5,5));
h3=wiener2(h,[5,5]);
subplot(1,5,1),imshow(g);
subplot(1,5,2),imshow(h);
subplot(1,5,3),imshow(h1);
subplot(1,5,4),imshow(h2);
subplot(1,5,5),imshow(h3);
%Removing speckle noise
g=imread('cameraman.tif');
h=imnoise(g,'speckle',0.1);
h1=medfilt2(h,[5,5]);
h2=ordfilt2(h,25,ones(5,5));
h3=wiener2(h,[5,5]);
subplot(1,5,1),imshow(g);
subplot(1,5,2),imshow(h);
subplot(1,5,3),imshow(h1);
subplot(1,5,4),imshow(h2);
subplot(1,5,5),imshow(h3);

程序原理如下: 

 1、part1,利用imnoise函数分别对图像加入高斯噪声、椒盐噪声和斑点噪声;对于高斯噪声,分别通过改变均值和方差得到不同的图像;对于椒盐噪声,通过改变噪声密度值得到不同的图像;对于斑点噪声,通过改变方差值得到不同的图像;然后使用函数imshow在图像窗口中显示每个图像。

 2、part2,使用函数medfilt2、ordfilt2和wiener2去除图像中添加的高斯噪声、椒盐噪声和斑点噪声,然后使用函数imshow在图像窗口中显示每个图像。

程序运行结果如下:

part1 

 图1:原始图像和加入不同均值和方差的高斯噪声后的图像

图2:原始图像和添加不同噪声密度的椒盐噪声后的图像 

图3:原始图像和添加不同方差散斑噪声后的图像 

part2

图4:原始图像、带有高斯噪声的图像以及使用函数medfilt2、ordfilt2和Wiener 2过滤的图像

 

图5:原始图像、带有椒盐噪声的图像以及使用函数medfilt2、ordfilt2和Wiener 2过滤的图像 

 图6:原始图像、带有斑点噪声的图像以及使用函数medfilt2、ordfilt2和Wiener 2过滤的图像

看到这里的小伙伴别忘了点个赞再走哦!

关注博主学习更多MATLAB数字图像处理知识 !

  • 16
    点赞
  • 71
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

海岛码农

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值