views:

100

answers:

2

Hi, im trying to implement a gaussian blur with the use of FFT and could find here the following recipe.

This means that you can take the Fourier transform of the image and the filter, multiply the (complex) results, and then take the inverse Fourier transform.

I've got a kernel K, a 7x7 Matrix and a Image I, a 512x512 Matrix.

I do not understand how to multiply K by I. Is the only way to do that by making K as big as I (512x512) ?

+6  A: 

Yes, 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. Alternatively, you can translate the resulting filtered image once you are done.

Another point: for small kernels not using the FFT may actually be faster. A 2D Gaussian kernel is separable, meaning that you can separate it into two 1D kernels for x and y. Then you instead of a 2D convolution, you can do two 1D convolutions in x and y directions in the spatial domain. For smaller kernels than may end up being faster than doing the convolution in the frequency domain using the FFT.

Dima
A: 

If you are comfortable with pixel shader and if FFT is not your main goal here, but convolution with gaussian blur kernel IS,- then i can recommend my tutorial on what convolution is

regards.

0x69