FFT centering convention #37
LouisDesdoigts
started this conversation in
General
Replies: 1 comment 3 replies
-
I'm not sure if this solves the problem or not but I found this while trolling through the # This needs to be an ifftshift, for machine-precision equivalence to MFT
# as tested by test_MFT_FFT_equivalence_in_OpticalSystem; ifftshift and fftshift are
# precisely equivalent for even-sized arrays but differ by 1 pixel offset for odd-sized
# arrays. The use of ifftshift here ensures the PSF is correctly centered in the center
# pixel for odd-sized arrays. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So numpy/jax FFT's always center the zero-frequency on a pixel center, even you use an even sized array. This is a possible problem because the PhysicalWavefront class defines the origin of its paraxial coordinate system to be the center of the array, ie pixel intersection for even sized arrays and pixel center for odd-sized arrays. Performing a series of FFT's followed by paraxial operations could lead to a drift between what is defined as paraxial for the Wavefront class and where the center/zero frequencies of the actual underlying arrays.
Presently I almost exclusively use MFT's which don't have this problem (or at least if they do can be fixed trivially).
One option is to calculate and add phase slopes inside the FFT propagation, but this solution doesn't feel very robust or general, so we should start to think about how we want to approach this, ideally without redefining what is the optical axis to match the consistently inconsistent FFTs.
Beta Was this translation helpful? Give feedback.
All reactions