2
$\begingroup$

I have a small 2D Gaussian image filter that I am currently applying as a window by convolution. I would like to do this in the Fourier domain as a single multiplication. I would like to convert my current small filter to the Fourier domain as it is with maximum possible fidelity.

I do not know the size of the image that I shall be applying it on and want to be able to dynamically change it for any image size. How do I go about doing this?

Can I scale my filter to the image size (square to rectangle), FFT the scaled and now distorted and multiply in the Fourier domain?

or

Should I FFT it first, scale up (square to rectangle) and distort the FFT and then multiply it?

I am not convinced that either is a correct approach. Are there any alternative ways?

I am working with this in MATLAB

$\endgroup$
1
  • 1
    $\begingroup$ Do you know the spatial expression for the filter? Gaussian filters have an analytic form in the Fourier domain as well. $\endgroup$ May 3, 2013 at 23:16

1 Answer 1

1
$\begingroup$

For a low-pass filter that is small compared to the image you can put your filter (unscaled) in the center of a square/rectangle the size and shape of your image (all the other pixels are 0), take the FFT and multiply the result in the Fourier domain.

Since you are using a Gaussian filter you could do something more efficient than that. The Gaussian filter is _ separable_ so you can actually create a 2D Gaussian filter by doing a 1D Gaussian filter in every row (column) in one dimension followed by a 1D Gaussian filter in every column (row) in the other dimension.

Second, the Fourier transform of a Gaussian is a Gaussian. So we can work in one dimension at a time, we know what we're going to get, and multiplying a Gaussian in the Fourier domain is also separable since $e^{-(x^2+y^2)}=e^{-x^2}e^{-y^2}$. The only question is what the standard deviation ($\sigma$) of the transformed Gaussian is going to be. The derivation is worked out on Mathworld as: $$ \mathcal{F}[e^{-ax^2}](k)=\sqrt{\frac{\pi}{a}}e^{-\pi^2k^2/a}. $$

$\endgroup$
2
  • 1
    $\begingroup$ The only trouble with doing this is that the image resulting may have circular (spatial) aliasing. If the image is $N\times N$ and the filter is $N \times N$ then the resulting (convolved) image needs to be $2N -1 \times 2N - 1$ to avoid such aliasing. $\endgroup$
    – Peter K.
    May 4, 2013 at 13:54
  • $\begingroup$ You are correct. I modified the opening paragraph. I think that the technique works for small low-pass filters. I hadn't thought about the more general case. $\endgroup$ May 5, 2013 at 3:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.