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

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

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

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

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

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

part2

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

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

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

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

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

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

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

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

Original: https://blog.csdn.net/qq_59049513/article/details/122598641
Author: 海岛码农
Title: 【数字图像处理】灰度图像中添加高斯噪声、椒盐噪声、斑点噪声以及利用不同方法(中值、排序、维纳滤波)去除各种噪声的matlab程序

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/632754/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球