I'm trying to do an FFT-based gaussian blur on a grayscale image, and it works, however it seems to introduce ringing artifacts to the result when compared to the expected direct filter. What can I do to mitigate this?
In reality I'm using quite a wide gaussian kernel, so I'd rather not use direct convolution for the blurring.
The left image is a regular blur, the right one is the FFT-based blur. Note the "ringing" especially in the top middle-left part of the right image. Also it seems like the blur is a bit stronger on the right for some reason.
import numpy as np from scipy import ndimage, misc import matplotlib.pyplot as plt ascent = misc.ascent()[300:450, 100:250].astype(np.float64) input_ = np.fft.rfft2(ascent) result = ndimage.fourier_gaussian(input_, sigma=1.5) result = np.fft.irfft2(result) fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(5, 2.5)) plt.tight_layout() plt.gray() ax1.imshow(ndimage.gaussian_filter(ascent, 1.5, mode='wrap', truncate=10)) ax2.imshow(result) plt.savefig("fourier gaussian blur test.png")
I apologize if this question is trivial, I don't know much about image processing.