# Image derivative in the Fourier space

It can be shown that the image derivative in the $x$ direction is given by: $$\frac{\partial f}{\partial x}=\frac{2\pi i}{N} \mathcal F^{-1}\left(u\cdot \mathcal F(f(x,y)\right)$$ where $N$ is the width of the image in the $x$ direction and $u$ denotes a variable in the fourier space ($F(u,v)$).

Now, in the image space, derivation is a convolution with this matrix: $$\partial_x =\left(\begin{array}{cc} -1 & 1\end{array}\right)$$

this means (from to convolution theorem) that the fourier transform of $\partial_x$ is a matrix $D(u,v)$ such that $D(u,v)=u$.

so I tried to see this in python, but something seems to be wrong here:

d = np.zeros((21,21))
d[10,10] = 1
d[10,9] = -1
D = np.fft.fft2(d)
plt.matshow(np.fft.fftshift(D))


Can anyonw see where I am wrong?

• Could you define df? – Tolga Birdal Dec 2 '16 at 23:19
• @TolgaBirdal it's just D – proton Dec 2 '16 at 23:22

The Fourier transform property in your first equation is for continuous time but the image is a discrete time signal. $\partial_x$ isn't exactly differentiation, it's a discrete time filter which does finite differencing.
Since you are only taking derivatives in one direction, let's think about a 1-D signal for simplicity (or, equivalently, let's assume your image has only one row). Let the signal be $f(x)$ and its continuous time Fourier transform $F(u)$. Then we have the transform pair $\frac{df(x)}{dx} \leftrightarrow j 2\pi u F(u)$. In discrete time, if $x[n] \leftrightarrow X[k]$, you can't really say $\{x[n]-x[n-1]\} \leftrightarrow j2\pi k X[k]$.
Instead, we can think of $\partial_x$ as a high pass filter. It then agrees with the intuitive meaning of the continuous time Fourier transform property too (where multiplying by $u$ attenuates lower frequencies more than higher frequencies). Try this code, to see the high pass response:
d = np.zeros(10000)