# Filter Learning Notes Bigdevil

2023-01-25   ES

On the principle of two -dimensional DFT, you can refer to the “Image Engineering Volume” published by Tsinghua, so the principle of two -dimensional DFT is repeated here. If you don’t understand, the effect image will not understand why.
So I call the library FFT2 (x) directly in the code;

``````% by keyhero
% img_fft.m
clear;
freq=fft2(lena);
freq = fftshift(freq);
ampt=abs(freq);
temp=max(ampt);
max_val=max(temp);
temp=min(ampt);
min_val=min(temp);
slope=255/(max_val - min_val);
for i=1:256
for j=1:256
temp(i,j)=uint8(slope*(ampt(i,j) - min_val));
if temp(i,j)~=0
temp(i,j)=256;
end
end
end
imgfft=uint8(temp);
subplot(121);imshow(lena);
subplot(122);imshow(imgfft);
``````

You will find that this is a messy image. It looks like a mess. The normal situation should be at the middle part of the high frequency and the low frequency is around. In fact, the image array is distributed like this, but it can only be displayed on the computer. The gray value to 255.
So, gray should be mapped, and mapping from MAX to 255

MATLAB displayed the value distribution as follows:

So there is a FOR loop in the above code, and in order to highlight the display effect, the pixel value is dual -value

The results after

are as follows:

It can be found that when the image display pixel value is normalized, it is relatively obvious in the middle part of the image (that is, the low -frequency part of the Fourier transformation), and the symmetry of the Fourier transformation of Fourier in the vertical and horizontal direction is more obvious, and Essence The reason why there are more low -frequency parts is determined by the pixel distribution of this image.

Thank you！

source