I=imread("cameraman.tif");figure(1);imshow(I);J=imnoise(I,"gaussian",0,0.02); figure(2);imshow(J);J=double(J);f=fft2(J); %採用傅立葉變換g=fftshift(f); %資料局陳平衡[M,N]=size(f);n1=floor(M/2);n2=floor(N/2);d0=10;for i=1:Mfor j=1:Nd=sqrt((i-n1)^2+(j-n2)^2);if d>=d0h1=1;h2=1+0.5;elseh1=0;h2=0.5;endg1(i,j)=h1*g(i,j);g2(i,j)=h2*g(i,j);endendg1=ifftshift(g1);g1=uint8(real(ifft2(g1))); %顯示理想高通濾波結果figure(3);imshow(g1);title("理想高通濾波結果")g2=ifftshift(g2);g2=uint8(real(ifft2(g2)));figure(4);imshow(g2); %顯示理想高通加強濾波結果title("理想高通加強濾波結果")
I=imread("cameraman.tif");figure(1);imshow(I);J=imnoise(I,"gaussian",0,0.02); figure(2);imshow(J);J=double(J);f=fft2(J); %採用傅立葉變換g=fftshift(f); %資料局陳平衡[M,N]=size(f);n1=floor(M/2);n2=floor(N/2);d0=10;for i=1:Mfor j=1:Nd=sqrt((i-n1)^2+(j-n2)^2);if d>=d0h1=1;h2=1+0.5;elseh1=0;h2=0.5;endg1(i,j)=h1*g(i,j);g2(i,j)=h2*g(i,j);endendg1=ifftshift(g1);g1=uint8(real(ifft2(g1))); %顯示理想高通濾波結果figure(3);imshow(g1);title("理想高通濾波結果")g2=ifftshift(g2);g2=uint8(real(ifft2(g2)));figure(4);imshow(g2); %顯示理想高通加強濾波結果title("理想高通加強濾波結果")