圖像處理問題描述:
1、圖像中分別加入不同方差的高斯噪聲、不同噪聲密度椒鹽噪聲和不同方差的斑點噪聲(Gaussian noise, salt &?pepper noise and speckle noise)
2、分別通過函數(shù)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函數(shù)分別對圖像加入高斯噪聲、椒鹽噪聲和斑點噪聲;對于高斯噪聲,分別通過改變均值和方差得到不同的圖像;對于椒鹽噪聲,通過改變噪聲密度值得到不同的圖像;對于斑點噪聲,通過改變方差值得到不同的圖像;然后使用函數(shù)imshow在圖像窗口中顯示每個圖像。
?2、part2,使用函數(shù)medfilt2、ordfilt2和wiener2去除圖像中添加的高斯噪聲、椒鹽噪聲和斑點噪聲,然后使用函數(shù)imshow在圖像窗口中顯示每個圖像。
程序運行結(jié)果如下:
part1?
?圖1:原始圖像和加入不同均值和方差的高斯噪聲后的圖像
圖2:原始圖像和添加不同噪聲密度的椒鹽噪聲后的圖像?
圖3:原始圖像和添加不同方差散斑噪聲后的圖像?
part2
圖4:原始圖像、帶有高斯噪聲的圖像以及使用函數(shù)medfilt2、ordfilt2和Wiener 2過濾的圖像
?
圖5:原始圖像、帶有椒鹽噪聲的圖像以及使用函數(shù)medfilt2、ordfilt2和Wiener 2過濾的圖像?
?圖6:原始圖像、帶有斑點噪聲的圖像以及使用函數(shù)medfilt2、ordfilt2和Wiener 2過濾的圖像
看到這里的小伙伴別忘了點個贊再走哦!文章來源:http://www.zghlxwxcb.cn/news/detail-468309.html
關(guān)注博主學習更多MATLAB數(shù)字圖像處理知識?!文章來源地址http://www.zghlxwxcb.cn/news/detail-468309.html
到了這里,關(guān)于【數(shù)字圖像處理】灰度圖像中添加高斯噪聲、椒鹽噪聲、斑點噪聲以及利用不同方法(中值、排序、維納濾波)去除各種噪聲的matlab程序的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!