Given a 2d spatial kernel $h$, I want to construct the corresponding frequency filter $H$. In theory, $H$ is simply obtained by calculating the DFT of $h$ using a FFT algorithm. But in practice, there are some considerations to be considered. First, if $H$ is used for filtering, zero-padding is required. Second, after zero padding, the original center of $h$ (i.e. center of $h$ before zero padding) must circularly-shift to the upper-left corner.
I know that zero padding is used to overcome wraparound errors. And I have observed, by experiment, shifting the original center to the upper-left corner prevents shifting the filtered image. But my question is why this is the case? That is, why not shifting the original center, leads to shifting the final image; and how shifting the original center resolves the problem?
The above image is obtained by filtering in the spatial domain using a Gaussian low pass filter.
The above image is obtained by filtering in frequency domain using Fourier transform of the same Gaussian low pass filter, without circularly shifting the kernel of the filter after padding.
The above image is the absolute difference of the spatial-domain filtered image and the frequency-domain filtered image (i.e. first and second image above). As you can see, not shifting spatial kernel after padding, leads to shifting the filtered image in frequency approach.