Filter and crop an image 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.


Questions:


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?
First, let's start with the wrong part of your post:


  to apply fft, images must have dimensions which are the multiple of power of 2.


This is incorrect. FFTs do not have to be a power of 2.  The only requirements for applying an FFT are that you can decompose the signal length into its prime factors and that you have an FFT that can deal with these prime factors.


  to apply the fft, the dimensions of the image and the mask must be equal.


This is correct. To do the point-wise multiplication in the frequency domain, it's easier to do when both image and kernel FFTs are the same size.


  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.


The power of 2, as pointed out before, is incorrect.

the width and heights of both image and the mask, round them is also incorrect.

Your second option:


  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.


is closer to the truth, but still incorrect.

Suppose your image is $N\times M$ and your kernel is $K \times L$. To use the FFT to do linear convolution you need pad both of them to be $(N + K - 1) \times (M + L - 1)$. If you don't you'll get time aliasing from the circular convolution.

Now, to answer your questions:


  So, in both of the cases we are actually obtaining oversized output images with padding. Am I right?


Yes, to avoid circular convolution results (and the associated "time" / "spatial" aliasing), you need to pad.


  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?


Yes. If you're interested in an in-place replacement (so that the resulting image aligns with the original unfiltered image), then you need to remove the padding.


  If YES, should I just crop the image? Or, is there any better way possible altogether from the ground up?


Yes, just crop the image at the right place.