Filter - Spatial Domain Versus Frequency Domain
It appears you need to study a bit on convolutional filtering of images, specifically on overlap add/ overlap save methods.

From the links I can see your objective is to apply the filter defined in the second equation i.e, the frequency domain one. The first link's accepted answer seems to be wrong (i didn't go through the code, clearly since the images shown by the paper and answer do not match).

Now the method you are using to apply the filter in the spatial domain is wrong. I'm assuming by padding you mean zero padding. The objective of zero padding before applying fft is to increase the resolution in the frequency domain. So imagine I have a 1D sine wave of 50 Hz. Taking fft of this signal would give a peak at the 50 Hz point with some additional values at different frequencies. This is because the sine is not pure sine since the signal is limited in time. If you had an infinitely long signal you would get a single value at 50 Hz. Padding the signal and then taking fft would still give the similar result but with more resolution on what additional frequencies exists.

In contrast convolution filter is essentially convolving 2 signals.
$$
y(t) = \int_{\tau = 0}^{\inf} h(\tau)x(t-\tau)d\tau
$$
In 2D, if we have a 3x3 filter kernel, we first multiply the first 3x3 block of the input with the kernel and then shift the kernel by one column. Then we multiply the next 3x3 with kernel and add the overlapping pixel values.

for small kernel sizes (say 3x3 or 5x5) this approach maybe faster. Using fft is alluring when working with large kernel sizes. The approach is go block by block and use the overlap save/add method (you can find a lot of info on this just google it for 2D). The reason we need to use overlap method is because fft facilitates circular convolution and not linear convolution (but circular convolution can be made to behave like linear convolution by adjusting the input and kernel sizes).

Once you understand the method then it is just deciding on the kernel size and using the equation for those u,v values. Hope this helps.