Original:
(0)
Code:
I=imread (' 1.jpg ');
I=rgb2gray (I);
I=im2double (I);
F=FFT2 (I);
F=fftshift (F);
F=abs (F);
T=log (f+1);
Figure
Imshow (t,[]);
Fourier transform:
(1)
Analysis Code:
1. I=imread (' 1.jpg ');
Read the image, no more talking.
2. I=rgb2gray (I);
Convert the image to grayscale, and if this is not the case, the resulting Fourier transform looks like this.
(2)
3. i=im2double (I);
The data format of the image is converted to double type, at this time the value range of the image from the original [0,255], changed to [0,1], in fact, do not convert, you can also do Fourier transform, but the Fourier transform image will be different, as shown in (3), you can compare with the figure (1) to see the effect , and sometimes the Fourier transform results from different people are not the same, maybe that's why
(3)
4. F=FFT2 (I);
Perform Fourier transform
5. F=fftshift (F);
To convert the Fourier transform image into quadrant, without this step, the result of the final output is this
(4)
6. F=abs (F);
To find the Fourier transform, we all know that the result of the Fourier transform is a complex number, including real real and imag imaginary parts, and ABS is the complex of the mold, after this step, the type of f from the plural double into a double, if not this step, MATLAB will give hints, Warning:displaying real part of complex input. The result of the final output is as follows.
(5)
7. T=log (f+1);
After the first few steps, we get the amplitude of the Fourier transform, but the Fourier transform has a very large range of values, MAXF = 2.04e+05,minf = 0.009, if not converted, it is shown in the figure (6), there is a small white dot in the middle
(6)
Then why use log (f+1)? As shown in 7, the X value between (0,1) is converted to a negative number after the log (x) transformation, while log (x+1) maps all x values to positive numbers and a smaller range of values.
(7)
8. Figure;imshow (t,[]);
The image is displayed with Imshow (t,[]) instead of Imshow (T). Because the range of T is still greater than [0,1],maxt=12.23,mint=0.009] even after the logarithmic transformation. Imshow (T) only displays the value of [0,1], and Imshow (t,[]) displays the image based on the range of values of the grayscale, which is equivalent to mapping [0.09,12.23] to [0,1] display.
Fourier transform an image using Matlab