1. 程式人生 > >【matlab】影象去噪的程式碼測試

【matlab】影象去噪的程式碼測試

%% 自己設定頻域的濾波視窗
girl=imread('F:\Users\*****\Pictures\CGS_stripe1.bmp');
girl=rgb2gray(girl);
girl=im2double(girl);
subplot(1,2,1);imshow(girl);%顯示原始影象
title('原始影象'); 
G=fft2(double(girl));% 二維傅立葉變換
G=fftshift(G);%象限轉換
subplot(1,2,2);imshow(log(abs(G)+1),[ ]);%顯示原始影象頻譜圖
title('原始影象頻譜圖');figure;
%構造理想低通濾波器,並用它濾波 [height width]=size(G); H(1: height,1: width)=0.9; x0= height/2; y0= width/2;%確定原點 for x=1:height for y=1:width if(sqrt((x- x0)*(x- x0)+(y-y0)*(y-y0))>15) %確定濾波半徑 H(x,y)=1; end F(x,y)=G(x,y)*H(x,y); end end imshow(log(abs(F)+1),[ ]);%顯示中間影象頻譜圖 title(
'中間影象頻譜圖'); g=ifft2(F);% 傅立葉反變換 figure;imshow(abs(real(g)),[ ]);%顯示處理後的影象 title('處理後的影象');