I am a big fan of fft convolution. So, I mostly try to avoid non-fft convolution.
Suppose, I am trying to convolute an image with another image. Suppose the first image is $512\times 512$, and, the mask image is $520\times 255$. How would we convolve them in the frequency domain?
Two major issues are to be addressed here,
to apply fft, images must have dimensions which are the multiple of power of 2. Our image and mask may or may not have dimensions of power of 2
to apply the fft, the dimensions of the image and the mask must be equal.
So, in order to address both issues, we can do any one of the following,
we can take the max of the width and heights of both image and the mask, round them to next power of 2 and, pad them.
we can take the sum of the widths and heights of the image and mask, round them to next power of 2 and, pad them.
So, in both of the cases we are actually obtaining oversized output images with padding. Am I right?
Suppose, I pad an image and get it FFT-filtered (Sharpened/Blurred/... and so on). So, I obtain a filtered image with padding. Now, I need to remove the padding to obtain the filtered image without padding. Am I correct?
If YES, should I just crop the image?
Or, is there any better way possible altogether from the ground up?
Suppose, this is the original image ($512 \times 512$),
And, suppose, the following is the filtered image with padding ($1024 \times 1024$),
Now, I want to obtain this,
How should I remove padding from this image?
Should I just crop, or, is there any better technique to get around this problem from start?