I have an image of a grid of holes. Processing it with numpy.fft.fft2
yields a nice image where I can clearly see periodicity, base vectors etc.
But how can I extract the lattice spacing?
The lattice points in real-space have a spacing of about 96px
, so the spacing in k-space would be 2*Pi / 96px = 0.065 1/px
.
Naturally, numpy can't return an image array with sub-pixel spacing, so it is somehow scaled - spacing in k-space is about 70px
.
But how is the scaling done and what is the exact scaling factor?
Units of
numpy.fft.fft2
's output frequency scale is incycle/full-length/pixel
, under the assumption that the input is periodic with a period corresponding to the full input length.So, if you have an
fft2
output with a size of6720 x 6720
pixels and with a spike at the 70th pixel, you may expect a periodic component in the spatial domain with a period of:Correspondingly, if you have an input image with a size of
6720 x 6720
pixels with elements that are repeating every 96 pixels, you will get a spike in the frequency domain at:While this is unit accurate, perhaps a simpler way to look at it is: