%% 自己設置頻域的濾波窗口 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('處理后的圖像');