1
$\begingroup$

Suppose, I have this kernel.

-1, -1, -1,
-1,  9, -1,
-1, -1, -1

(1) Can this kernel be used in an FFT-based convolution?

But,

(2) What could be the reason of my failure?

$\endgroup$
  • 2
    $\begingroup$ The bounty doesn't change that it's not quite clear what you're asking. $\endgroup$ – Jazzmaniac Aug 23 '16 at 19:54
  • $\begingroup$ this is now a pretty different question than it originally was $\endgroup$ – Marcus Müller Aug 24 '16 at 10:57
  • $\begingroup$ @MarcusMüller, I had nothing left to do. $\endgroup$ – user18425 Aug 24 '16 at 11:26
1
+50
$\begingroup$

To answer your question:

  1. Can easily be done.
    One must remember that the short signal (The Kernel) must be padded (With zeros) to have the same size as the image before the DFT conversion.
    Once they have the same size all needed is to convert into the Frequency Domain have element by element multiplication and transform back.
    A side note would be that this way you assume periodic boundary condition.
  2. I'm not a C# / C Coder.
    I can provide you a MATLAB reference if needed.
    Just make sure you do the following steps:

    • Pad the kernel to the image size (Pad it with zeros to the right and left).
    • Convert into the Frequency Domain.
    • Multiply Element by element.
    • Convert back to the spatial domain.

2 Remarks:

Enjoy...

$\endgroup$
  • $\begingroup$ "Just make sure you do the following steps: ... ... ... " --- Actually, I am following the same steps, but, for some reason it's not working. $\endgroup$ – user18425 Aug 24 '16 at 6:28
  • $\begingroup$ Would it help if I added MATLAB Code? Thank You. $\endgroup$ – Royi Aug 25 '16 at 7:42