2
$\begingroup$

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?

$\endgroup$
2
  • $\begingroup$ Could you define df? $\endgroup$ Commented Dec 2, 2016 at 23:19
  • $\begingroup$ @TolgaBirdal it's just D $\endgroup$
    – proton
    Commented Dec 2, 2016 at 23:22

2 Answers 2

2
$\begingroup$

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)
d[0] = -1.0
d[1] = 1.0
D = np.fft.fft(d)
plt.plot( np.abs(D) )

enter image description here

$\endgroup$
1
$\begingroup$

(picks up the chalk)

I believe fervently that, in the 2D image space, this rotation to grad is useful:

  • $M = M$: (no rotation)
  • $a = 0, 90, 180, 270, 360$ degrees, or $\left[ 0 , 360 \right]$ degress
      1. N = 2dcfft(M); The elements are cos and sin, recall that?
      1. O = e^-ia(M); Element by element component rotation, ok?
      1. P = 2dicfft(O); Image reformation.

(offers chalk, no takers)

Note for $a = 0$, or $360$ degrees, $P = M$ to computational accuracy. So, WTF happens in between? Well, it's all about pencil sketches and modeling for art classes. I do that. And in the studio, I hold still, shut TF up, and think about the brain dynamics.

In between:

At $a = 90$, $O = \left| \nabla \left( M \right) \right|$. The other angles are left as an exercise for the interested reader!

Cheers from Dana at Replikon Dot Net Mathcad 6.0 Plus!

(chalk returned)

$\endgroup$

Your Answer

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

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