?? 用濾波器祛除圖象噪聲.m
字號:
%用濾波器祛除圖象噪聲(分別用均值濾波,中值濾波,及維納濾波器祛除加入高斯噪聲的圖象)
I=imread('C:\boat.png');
J=imnoise(I,'gaussian',0,0.002); %加入高斯噪聲
%進行均值濾波
h=fspecial('average',3); %fspecial函數用于產生預定義濾波器
I2=uint8(round(filter2(h,I))); %filter2函數用于圖像濾波,此處h是濾波參數(均值),I是要處理的圖像
%進行中值濾波
I3=medfilt2(J,[3,3]); %medfilt2函數用于圖像的中值濾波
%進行維納濾波
I4=wiener2(J,[3,3]);%進行一次維納濾波
I5=wiener2(I4,[3,3]);%進行二次維納濾波
subplot(2,3,1),imshow(I),title('原圖象')
subplot(2,3,2),imshow(J),title('加噪聲圖象')
subplot(2,3,3),imshow(I2),title('均值濾波后圖象')
subplot(2,3,4),imshow(I3),title('中值濾波后圖象')
subplot(2,3,5),imshow(I4),title('維納濾波后圖象')
subplot(2,3,6),imshow(I5),title('兩次維納濾波后圖象')
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -