Matlab Image Fourier Transform

Matlab implements Fourier transform (two-dimensional)

Main function:

fft2(); fftshift();

Implementation code:

img = zeros(512,512);             %构建一个512*5120矩阵 (黑色)

img(224:278,224:296) = 1;        %224278行和224296列设为1(白色)

img_1 = fft2(img);                                                %求傅里叶变换

img_2 = fftshift(img_1);                                           %把原点移至矩阵中心

img_3 = log(1+abs(img_2));                                        %对数变换

subplot(2,2,1); imshow(img); title('原图像');

subplot(2,2,2); imshow(abs(img_1),[ ]); title('傅里叶频谱');

subplot(2,2,3); imshow(abs(img_2),[ ]); title('频谱移至中心');

subplot(2,2,4); imshow(img_3,[ ]); title('对数变换后');

operation result:

insert image description here

Guess you like

Origin blog.csdn.net/LPYchengxuyuan/article/details/121308988
Recommended