Convolution in the spatial domain vs frequency domain [closed]

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?

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

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...

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