2

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:

  1. zero-pad the kernel up to (M+U-1) x (N+V-1)
  2. take the 2-D fft of the kernel
  3. zero-pad the image up to (M+U-1) x (N+V-1)
  4. take the 2-D FFT of the image
  5. multiply FFT of kernel by FFT of
  6. 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 :-)

Community
  • 1
  • 1
weiwen
  • 446
  • 6
  • 16
  • 1
    There is no point using a frequency domain method for such a small kernel - just filter using direct (spatial domain) convolution. – Paul R Nov 08 '13 at 08:12
  • @PaulR Thanks! Yes, This using of 3x3 kernel is just a try. Is there any frequency domain filt method to obtain better denoise effect than doing convolution in spatial domain? That's actually what I'm looking for. :) – weiwen Nov 08 '13 at 09:03
  • It depends on what kind of noise you have - sometimes a non-linear filter such as a median filter is more appropriate than a linear filter. – Paul R Nov 08 '13 at 09:11
  • @PaulR Thanks for your kindly attention again :-) Let me make myself more clear. Actually the images I deal with are some paintings, so this is the first step in which I intend to make them "better" for the following steps to process (e.g. edge detection). I think it is the features of paintings (uneven color mixing while painting) together with some environmental implication that make the images contain noises (seems High frequency?). – weiwen Nov 08 '13 at 10:39
  • (continues...) I tried median filter and Gaussian filter in spatial domain, and the former seems perform better. But there still exist considerable noises when I applied the Sobel edge detector. So now I'm wondering whether there is a different way to block high frequency noises in frequency domain. – weiwen Nov 08 '13 at 10:42

0 Answers0