# Magnitude of gradient in frequency domain

I'm learning some basics of image processing. Recently I've read about image filtering and two-dimensional Fourier transform, because I'm preparing for exam. And I have one question I don't know answer for: is it possible to do filtering in frequency domain (by using Fourier transform), which in spatial domain is implemented by computing magnitude of gradient of the image?

I know that gradient operator is defined: $$\nabla f \equiv grad(f) = \begin{bmatrix}g_{x} \\ g_{y}\end{bmatrix}$$ and the magnitude of gradient: $$M(x,y) = \sqrt{g_{x}^{2} + g_{y}^{2}}$$ In spatial domain we can use gradient to find edges. High frequencies are responsible for edges. High frequency means the rate of change is high, thus gradient has high value.

But can we do similar thing in frequency domain? Has the magnitude of gradient operator any equivalent in frequency domain?

Remember that as part of computing the gradients of an image, you are really just convolving your image, with (two) spatial filters. This then gives you two 'gradient' images, which you can then combine.

For example, to compute the x-direction-gradient-image $G_x$, you would convolve your image with a filter $f_x$ that might look like this $\begin{bmatrix} 1 & 0 & -1\end{bmatrix}$. Similarly, to attain the y-direction-gradient-image, $G_y$, you might convolve your image with a filter $f_y$ that looks like this $\begin{bmatrix} 1 \\ 0 \\ -1\end{bmatrix}$.

Then, your final gradient image would be $G = \sqrt{G_x^2 + G_y^2}$.

So far so good. However, you don't need to do the convolution pixel by pixel. Instead, you could simply take the 2D DFT of $f_x$, multiply it pixel by pixel with the 2D DFT of the image, and then take the 2D IDFT back into the spatial domain. This would then also give you $G_x$. (Do the same to find $G_y$).

So the answer is at least a partial yes, in that you can compute the x and y gradient images via the FFT algorithm, (an implementation of the DFT), and then simply treating each of them as an element in a vector, and finding the L2 norm.

• It is clear that the calculation could be done in the frequency domain. But is there a filter defined in frequency domain that can be used to calculate the gradient magnitude? – cebe Jul 19 '14 at 15:46
• @cebe The gradient is a non-linear operation on the image, as can be seen from the formula. Canonical filtering operations however are linear operations, and so there cannot be an LSI filter that can get you the gradient directly, no. – Tarin Ziyaee Jul 19 '14 at 19:41
• great, adding that to your answer will make it perfect. Thanks! :) – cebe Jul 20 '14 at 21:19