I'm dealing with a small project with OpenCV & C++, maybe the following questions are naive, but I'll be very grateful if anyone could offer help.
Being new here, I don't have enough reputation to post images, so I'll try to make it clear.
I'm trying to denoise an image (MxN = 200x200 Mat) in frequency domain,
and say I have a UxV=3x3 Gaussian kernel {{0, -1, 0},{-1, 4, -1},{0, -1, 0}}, and the expected steps are:
- zero-pad the kernel up to (M+U-1) x (N+V-1)
- take the 2-D fft of the kernel
- zero-pad the image up to (M+U-1) x (N+V-1)
- take the 2-D FFT of the image
- multiply FFT of kernel by FFT of
- image take inverse 2-D FFT of result
Both The result of step 2 (fft of the kernel) and the final result (filted image) seems right, but then I found this answer:
you do need to make K as big as I by padding it with zeros. Also, after padding, but before you take the FFT of the kernel, you need to translate it with wraparound, such that the center of the kernel (the peak of the Gaussian) is at (0,0). Otherwise, your filtered image will be translated.
That's what I didn't do. But how could the result seems acceptable? So I'm now wondering what's the difference between whether moving the kernel to make its center is at (0, 0) before fft?
Here comes my 2nd question. If we got an shifted fft of an image (with the 0 frequency in the middle), can I just do this to obtain a 'low-pass' effet:
For the pixels whose distance from the center is bigger than a threshold, set their value 0.
(I think it's straight forward, but haven't found some similar methods widely used.)
Thank you VERY much for offering any help :-)