二維圖像的傅里葉變換


背景

Matlab Example

img=rgb2gray(imread("image1.jpg"));
freq=fftshift(fft2(im2double(img)));
fout=log(abs(freq)+1.001);
subplot(2,1,1),imshow(img);
subplot(2,1,2),imshow(fout,[]);

Play More

f=zeros(32);
f(14,16)=1;
f(18,16)=1;
img=fftshift(fft2(f));
iout=abs(img);
subplot(2,2,1),imshow(f);
subplot(2,2,2),imshow(iout,[]);

f=zeros(32);
f(14,14)=1;
f(18,18)=1;
img=fftshift(fft2(f));
iout=abs(img);
subplot(2,2,3),imshow(f);
subplot(2,2,4),imshow(iout,[]);

Naive 的濾波示例

img=imresize(rgb2gray(imread("image1.jpg")),0.2);
freq=fftshift(fft2(im2double(img)));
fout=log(abs(freq)+1.001);
subplot(2,2,1),imshow(img);
subplot(2,2,2),imshow(fout,[]);

[h,w]=size(freq);
cx=w/2;
cy=h/2;
for y=1:h
    for x=1:w
        dx=abs(x-cx);
        dy=abs(y-cy);
        if dx>=10 || dy>=10
            freq(y,x)=0;
        end
    end
end

fout2=log(abs(freq)+1.001);
subplot(2,2,3),imshow(fout2,[]);

img2=mat2gray(abs(ifft2(ifftshift(freq))));
subplot(2,2,4),imshow(img2,[]);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM