FFT 2D Convolution - Question

Started by August 30, 2011
Hello, I have a question, If I'm doing the FFT Convolution the right way because I don't get the wanted results. ( I am using the kissFTT library for c )

I load an image from a file. I filter out the argv values and put them into two arrays ( ar[] and gb[] )

they look like this:

ar[0].r = alpha;
ar[0].i = red;
gb[0].r = green;
gb[0].i = blue;

Now let's say the image has a size of 512*512 and I want to convolve it with a kernel of 50*50;

--I pad out the source image with zeros to a size of 562 * 562 with the source image in the MIDDLE and zeros on the 4 sides.

--I pad out the kernel to a size of 562 * 562 with zeros so that the actual kernel values are in the MIDDLE

--I fill the imaginary part of the kernel with zeros

Then I transform ar, gb and kernel into frequency space.

How should I multiply them then? Is it correct to do:

ar[0].r = ar[0].r * kernel[0].r;
ar[0].i = ar[0].i * kernel[0].r;
gb[0].r = gb[0].r * kernel[0].r;
gb[0].i = gb[0].i * kernel[0].i;


Please tell me, if I'm thinking right or wrong, and if I have to do any other steps to perform a convolution on a image;