[デジタル画像処理] グレースケール画像にガウス ノイズ、塩胡椒ノイズ、スペックル ノイズを追加し、さまざまな方法 (メディアン、並べ替え、ウィナー フィルター) を使用してさまざまなノイズを除去する Matlab プログラム

画像処理の問題の説明:

1. 分散の異なるガウスノイズ、ノイズ密度の異なるソルト&ペッパーノイズ、分散の異なるスペックルノイズ(ガウスノイズ、ソルト&ペッパーノイズ、スペックルノイズ)をそれぞれ画像に追加します 2. medfilt2、ordfilt2の追加機能および Wiener 2 は、
一部のノイズ (ガウス ノイズ、ソルト&ペッパー ノイズ、スペックル ノイズ) を除去するために使用されます。

各部のプログラムコードは以下の通りです。

%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. パート 1、関数 imnoise を使用して、ガウス ノイズ、塩コショウ ノイズ、スペックル ノイズをそれぞれ画像に追加します。ガウス ノイズの場合は、平均と分散をそれぞれ変更することで異なる画像を取得します。塩コショウ ノイズの場合は、次のようにして異なる画像を取得します。ノイズ密度の値を変更し、スペックル ノイズの場合は、分散値を変更してさまざまなイメージを取得し、関数 imshow を使用してイメージ ウィンドウに各イメージを表示します。

 2. パート 2 では、関数 medfilt2、ordfilt2、wiener2 を使用して、画像に追加されたガウス ノイズ、塩胡椒ノイズ、スペックル ノイズを除去し、関数 imshow を使用して各画像を画像ウィンドウに表示します。

プログラムを実行した結果は次のようになります。

パート1 

 図 1: 元の画像と、異なる平均と分散を持つガウス ノイズを追加した後の画像

図 2: 元の画像と、異なるノイズ密度の塩胡椒ノイズを追加した後の画像 

図 3: 元の画像と、異なる分散を持つスペックル ノイズを追加した後の画像 

パート2

図 4: 元の画像、ガウス ノイズを含む画像、および関数 medfilt2、ordfilt2、および Wiener 2 でフィルタリングされた画像

 

図 5: 元の画像、塩胡椒ノイズを含む画像、および関数 medfilt2、ordfilt2、および Wiener 2 でフィルタリングされた画像 

 図 6: 元の画像、スペックル ノイズのある画像、および関数 medfilt2、ordfilt2、および Wiener 2 でフィルタリングされた画像

これを見た友達は、離れる前に「いいね!」することを忘れないでください。

ブロガーをフォローして、MATLAB デジタル画像処理について詳しく学んでください。

おすすめ

転載: blog.csdn.net/qq_59049513/article/details/122598641