I am familiar with the regular way of applying a high pass filter on an image:
np.fft.fft2
on an image.np.fft.fftshift
so that the low frequencies are centered.np.fft.fftshift
and inverse Fourier transformation np.fft.ifft2
to get the corresponding image in spatial domain.If my understanding is correct, when we follow these steps, low frequencies lie near the center in Fourier domain image.
How do we apply np.fft.fft2
so that high frequencies instead of low frequencies are centered?
Additional info: I came across this particular way of applying a high pass filter in the following paper 'A Fourier Perspective on Model Robustness in Computer Vision' by Yin et. al. https://arxiv.org/abs/1906.08988
I am curious how they actually implemented it.
To not have low frequencies in the center of a 2D array, you need not to apply the np.fft.fftshift
. Indeed, this function swap half parts of the image to put the low frequency (initially near the borders) in the center.
Note that the high frequencies will not be exactly in the center but on the cross-shaped location. The bellow image shows an unshifted FFT computation of an image. The orange part is the highest frequencies while the lowest are located in the corner.
If you really need the high-frequencies to be only in the center (and not on the cross-shaped location), then you need to perform a re-projection. However, please not that this operation will likely destroy partially the high-frequencies due to diffusion. AFAIK, there is no way to (fully) prevent this.