Ethan Montag
2017-02-21 16:02:03 UTC
If I make an image of a horizontal sine wave grating, f, I know that in the 2D fft, the peak location can be interpreted as the frequency like this:
% f is n rows by m columns
F = fft2(f);
S = abs(F);
Discounting the DC at (1,1), I can find the peak in the first row.
Say it is at (1, 11). I can subtract 1 from the column location (Matlab indexing) and know that there are 10 cycles per the m columns of the grating. So the distance from the origin gives me the frequency. E.g. (10/m)cycles per pixel
The same thing occurs for a vertical grating. If I rotate the grating 90 degrees and the image is square (m=n), the peak will be at (11,1).
However if the image is a rectangle, the location of the peak is different. If the image height is half the width, then the peak will be at (6,1) meaning that there are 5 cycles per n rows of the image. This is the same frequency in terms of cycles per pixel.
So I made a very large horizontal sine grating image and rotated it 0 to 90 deg and cropped a rectangular part from the middle to get rotated gratings that fill the image. When I do the fft,
I can find the peak (r, c) and calculate the distance from the origin (1,1). But I can't figure out how to get the frequency of the peak. The distance from the origin gives the wrong answer (except the first row and column) and I tried some weighting functions but I couldn't figure it out. (The data looks like there is some sort of sinc function involved but I'm not sure.)
I am looking for the relationship where I can calculate the spatial frequency for any location(r,c) in a 2D FFT from a rectangular shaped image: G(r-1,c-1, m, n) = special frequency.
Does anyone have any ideas.
% f is n rows by m columns
F = fft2(f);
S = abs(F);
Discounting the DC at (1,1), I can find the peak in the first row.
Say it is at (1, 11). I can subtract 1 from the column location (Matlab indexing) and know that there are 10 cycles per the m columns of the grating. So the distance from the origin gives me the frequency. E.g. (10/m)cycles per pixel
The same thing occurs for a vertical grating. If I rotate the grating 90 degrees and the image is square (m=n), the peak will be at (11,1).
However if the image is a rectangle, the location of the peak is different. If the image height is half the width, then the peak will be at (6,1) meaning that there are 5 cycles per n rows of the image. This is the same frequency in terms of cycles per pixel.
So I made a very large horizontal sine grating image and rotated it 0 to 90 deg and cropped a rectangular part from the middle to get rotated gratings that fill the image. When I do the fft,
I can find the peak (r, c) and calculate the distance from the origin (1,1). But I can't figure out how to get the frequency of the peak. The distance from the origin gives the wrong answer (except the first row and column) and I tried some weighting functions but I couldn't figure it out. (The data looks like there is some sort of sinc function involved but I'm not sure.)
I am looking for the relationship where I can calculate the spatial frequency for any location(r,c) in a 2D FFT from a rectangular shaped image: G(r-1,c-1, m, n) = special frequency.
Does anyone have any ideas.