3
$\begingroup$

I'm currently learning about Fourier transform, but find the differences between spatial domain and frequency domain a bit confusing at times.

Let's say I would like to perform convolution of an image with a Gaussian kernel. As far as i understand the Fourier transform of a Gaussian is also a Gaussian i.e the Fourier transform of

$$ g(x,y;\sigma) = \frac{1}{2\pi\sigma^2} \cdot e^{- \frac{x^2+y^2}{2\sigma^2}} $$ is $$ G(x,y;\sigma) = e^{- 2\pi\sigma^2(x^2+y^2)} $$ However if I directly construct a kernel using $G(x,y;\sigma)$ the output kernel looks completely different from first computing $g(x,y;\sigma)$ and then doing the FFT. What is the correct approach here? I hope the question is clear, but it is essentially how I can construct a gaussian kernel directly in frequency space so i do not have to FFT the kernel.

$\endgroup$
4
  • 1
    $\begingroup$ Indeed, $\mathscr{F}\{g(x,y,σ)\} = G(k_x,k_y,σ)$. What do you mean "the output kernel looks completely different from first computing $g(x,y;σ)$ and then doing the FFT"? Are you doing it right? I mean, when you compute in the coordinate domain, you do a convolution with the kernel, and when you compute in the frequency domain, you simply multiply the image Fourier transform and $G(k_x,k_y,σ)$. $\endgroup$
    – V.V.T
    Mar 8 '21 at 11:32
  • $\begingroup$ I mean that if I first compute the kernel with a gaussian and then the FFT of that gaussian kernel(and shift to center the frequency domain), then the result is different from directly computing what is believe is the FFT of the gaussian. Maybe $x$ and $y$ are different from $k_x$ and $k_y$ and this is where i am mistaken? $\endgroup$
    – sn3jd3r
    Mar 8 '21 at 11:51
  • $\begingroup$ I do not understand what you mean "Maybe $x$ and $y$ are different from $k_x$ and $k_y$ ". It is a convenience to use different characters to denote variables in different domains, and, yes, $x$ is not $k_x$ and $y$ is not $k_y$. $x$, $y$ are measured in meters and $k_x$, $k_y$, in inverse meters, 1/m units. Compare the units for time and frequency domain variables, $t$ [second] and $ω$ [Hertz]. "Hertz" is an inverse "second". $\endgroup$
    – V.V.T
    Mar 8 '21 at 12:08
  • $\begingroup$ Different how? Is the resulting filter big in the center and drops off at the sides? Does it not conform to a Gaussian shape? Does it have a lot of imaginary values running around? There's a lot of that it could be partially right that one can only recognize with experience, but to help you out with that we need to know differently how. $\endgroup$
    – TimWescott
    Sep 7 '21 at 14:07
1
$\begingroup$

You can check numerically that fft(g) = G, that will be easier to analyze than the filtered result. At least you can easily plot it and identify if the coefficients are shifted, flipped, or scaled. One thing easy to do incorrectly is the determination of the frequency corresponding to each coefficient. I would strongly recommend that you first approach the 1D version of your problem. See Circular wrapping of an asymmetric function (in DFT calculations) for an example of 1D filtering I wrote for a related question.

$\endgroup$
1
  • $\begingroup$ Note that any straight-line section through a 2D Gaussian in Cartesian coordinates should be Gaussian. So if you take the Fourier transform of a 2D Gaussian that's a good size, then test the result for $x = 0$ and $y = 0$, it should be Gaussian, too. And that's something you should be able to easily plot. $\endgroup$
    – TimWescott
    Sep 7 '21 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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