1
$\begingroup$

More precisely, let's say I apply a 45 degrees rotation to an image (in the spatial domain) say, in Matlab :

Ir=imrotate(myImage,45,'crop');
FT_I=fft2(I);

In the magnitude, i.e. abs(FT_I) is it clear that the spectrum has be rotated too.

For example, trying to reconstruct/sort of "unrotate", wrt center (with shifted DC in center), in the frequency domaine like:

FT_Is=fftshift(FT_I);
I_rec_FT=abs(ifftshift(imrotate(FT_Is,45,'crop'))).*exp(-i*angle(ifftshift(imrotate(FT_Is,-45,'crop'))));

...does not make sense (ifft2()) does not show an image that seems at all sort of unrotated.

Therefore, what exactly happens with the phase part?

enter image description here

"unrotated" unsuccessfully, image.

enter image description here

From these spectra, one can clearly see that the magnitude spectrum has been rotated by the same amount. However, the phase has a random character, and one cannot visually see anything (from the phase image). I would like to know what mathematically and intuitively happens with the phase?

Moreover, it is mentioned in this lecture that rotation in spatial (or temporal) domain results in rotation in frequency domain, by the same angle, but unfortunately no precision are given w.r.t. the phase.

enter image description here

Moreover its stated in this lecture of Verona University and I heard it from image processing professors...

http://www.di.univr.it/documenti/OccorrenzaIns/matdid/matdid916567.pdf

https://www.slideshare.net/chinnannanperiasamy/fourier-transform-44374579

$\endgroup$
  • $\begingroup$ "it's clear the spectrum has been rotated, too": How is that clear? $\endgroup$ – Marcus Müller Aug 9 at 7:01
  • $\begingroup$ by looking at the magnitude image $\endgroup$ – Machupicchu Aug 9 at 7:24
  • $\begingroup$ Um, could you explain that? Maybe with a picture? $\endgroup$ – Marcus Müller Aug 9 at 7:27
  • $\begingroup$ yes I just added the spectra, please look at them. I did a 90 degrees rotation this time because i think its easier to see. $\endgroup$ – Machupicchu Aug 9 at 8:15
  • $\begingroup$ Can you really go ahead and try with a 45° rotation. It doesn't work with any rotation that's not a multiple of 90°. I was wondering whether I was misunderstanding you, but this showed that you're under a misconception. $\endgroup$ – Marcus Müller Aug 9 at 8:47
1
$\begingroup$

This question has a simpler answer for the 2-D continuous-space Fourier transform but itsdDiscrete Fourier transform based verification requires some elaboration and careful implementation as @MarcusMüller has already mentioned.

On the continuous-space it can be shown that rotating an image $f(x,y)$ by $\theta$ radians CCW (counter-clock wise) on the $xy$ plane, will also rotate the corresponding CSFT (continuous-space Fourier transform) $F( \Omega_1 , \Omega_2 )$ by $\theta$ radians CCW :

CCW rotation by $\theta$ on the $xy$ plane can be described by the following transform:

$$ x' = x \cos(\theta) - y \sin(\theta) \\ y' = x \sin(\theta) + y \cos(\theta) \tag{1} $$

where $x,y$ are the original coordinates and $x',y'$ are the rotated (new) coordinates. A corresponding inverse rotation by $\theta$, (or CCW by $-\theta$ ) has the following transform :

$$ x = + x' \cos(\theta) + y' \sin(\theta) \tag{2} \\ y = - x' \sin(\theta) + y' \cos(\theta) $$

Given the original image $f(x,y)$, we rotate it CCW by $\theta$ to obtain the rotated image $g_r(x,y)$, then the following will hold :

$$ g_r(x,y) = f( x \cos(\theta) + y \sin(\theta) , - x \sin(\theta) + y \cos(\theta) ) \tag{3} $$

Note that in Eq. (3), the arguments of the original function $f(\cdot,\cdot)$ are described by the inverse rotation relation to coordinates $x,y$ of $g_r(\cdot,\cdot)$.

The CSFT of the rotated image $g_r(x,y)$ is:

$$ \boxed{ G_r(\Omega_1,\Omega_2) = \iint_{-\infty}^{\infty} g_r(x,y) e^{-j( \Omega_1 x + \Omega_2 y) } dx dy} \\ $$

$$ \begin{align} &= \iint f( x \cos(\theta) + y \sin(\theta) , - x \sin(\theta) + y \cos(\theta) ) e^{-j( \Omega_1 x + \Omega_2 y) } \tag{4} \\ &= \iint f( x' , y' ) e^{-j[ \Omega_1 (x' \cos(\theta) - y'\sin(\theta)) + \Omega_2 (x' \sin(\theta) + y' \cos(\theta)) ]} dx' dy' \tag{5}\\ &= \iint f( x' , y' ) e^{-j[ ( \Omega_1 \cos(\theta) + \Omega_2 \sin(\theta) ) x' + (-\Omega_1 \sin(\theta) + \Omega_2 \cos(\theta)) y' ]} dx' dy' \tag{6}\\ &= F( \Omega_1 \cos(\theta) + \Omega_2 \sin(\theta) , -\Omega_1 \sin(\theta) + \Omega_2 \cos(\theta) ) \tag{7} \end{align} $$

In moving from step (4) to (5), make the substitution defined in Eqs (1) and (2), and note that the Jacobian of the transformation is unity. See page 778 of Calculus Adams 6E for an explanation and derivation of this result.

In moving from step (6) to (7) we simply recognise the expression in Eq.(6) as the CSFT of the original signal $f(x,y)$ with arguments given according to relation in Eq.(3) given as below:

$$G_r(\Omega_1,\Omega_2) = F( \Omega_1 \cos(\theta) + \Omega_2 \sin(\theta) , -\Omega_1 \sin(\theta) + \Omega_2 \cos(\theta) ) \tag{8} $$

Eq.(8) is analogous to Eq.(3) and states that the CSFT of the rotated image is also roated by the same amount; $\theta$ CCW. This, therefore, means that phase is also rotated by the same amount.

Verification of this result within the discrete-space sequences $f[n,m]$ and their corresponding DFT sequences requires specific care given to potential aliasing caused by inadequate sampling of the rotated image $g_r(x,y)$, and proper circular extension of the rotated sequence $g_r[n,m]$.

Without going into mathematical details, I'll put the results of the following implementation of the rotation using Matlab/ Octave (rotation is wrt upper left corner)

enter image description here

We can still see artefacts of non-ideal implementation...

Note that with typical images it's harder to realize the ideal result.

$\endgroup$
  • $\begingroup$ interesting answer thanks, i will read it ASAP. $\endgroup$ – Machupicchu Aug 12 at 13:32
  • $\begingroup$ This is exactly the answer I was looking for. However, I am surprised that in all lectures I've had so far, nothing was mentioned about the artifacts with the DFT. $\endgroup$ – Machupicchu Sep 3 at 14:24
  • $\begingroup$ yes because it will be quite complicated to do so... $\endgroup$ – Fat32 Sep 3 at 18:51
  • $\begingroup$ Hum, it is always a but frustrating when the theory does not exactly coincide with practice. Maybe a bit like when Obi-Wan Kenobi said to Luke Skywalker that his father was killed by Darth Vader (cf. episode 4), but then in fact it was a metaphor, and not the practical truth. $\endgroup$ – Machupicchu Sep 4 at 8:47
  • $\begingroup$ hmm that's a nice metaphor... Unfortunately the discrete-space domain does not permit rotations on the sequence unless it's re-sampled from its continuous space interpolation. And these are non-perfect operations in practice, hence it's quite hard to realize it in practice... $\endgroup$ – Fat32 Sep 4 at 20:35
0
$\begingroup$

You're under a misconception:

I apply a 45 degrees rotation to an image (in the spatial domain), … clear that the spectrum has be rotated too.

If you rotate an image $K$ by an angle $\alpha$, say we call the rotation operation $R_\alpha(K): \mathbb R^{w\times h}\mapsto \mathbb R^{w\times h}$, the $\text{DFT}\left(R_\alpha(K)\right)\ne R_\alpha\left(\text{DFT}(K)\right)$.

That's easy to see. Assuming an image $K$ that's completely 0 but for a single pixel, straight in the middle of the image. Then, for any angle $\alpha$, $R_\alpha(K)=K$, i.e. the image is invariant to rotation.

It's DFT is not: It's a vertical/horizontal cross. Rotating that cross yields a different image that is not the same as the original. The spectrum is not invariant to rotation. Hence, the statement that rotation of spatial domain is equivalent to rotation of frequency domain must be false.

The difference is that it's important how large (especially: finite) your image is. If it's infinite, then the rotation argument holds, but then that's not a property of the 2D-DFT (==2D-FFT), because that assumes finite images.

The pictures you're showing aren't correct in the narrow sense of the word:

I tried to reproduce that, and as predicted, it doesn't look like your literature:

reproduction

From top to bottom, left to right: Original image, rotated by 50°; |DFT| logarithmic (because otherwise hard to see at all) of original image, of rotated image.

Why? Probably because these slides were done by physicists confusing a narrow excerpt of the output of Fourier optics with a DFT.

You'll notice that in the DFT of the rotated image, you get "crosses" in the corners of the image. That's the circular nature of the DFT at work!

$\endgroup$
  • $\begingroup$ Then how do you interpret slide 1 DFT properties rotation: (i hope you can read PDF files?): di.univr.it/documenti/OccorrenzaIns/matdid/matdid916567.pdf $\endgroup$ – Machupicchu Aug 9 at 9:24
  • $\begingroup$ or here (p3) eee.hku.hk/~work8501/WWW2008/ho4.pdf : "In words, that means an anti-clockwise rotation of a function by an angleθimplies that its Fouriertransform is also rotated anti-clockwise by the same angle" $\endgroup$ – Machupicchu Aug 9 at 9:27
  • $\begingroup$ Hehe, they're omitting that the signal is finite! What you write is correct, but only if you think of finitely large images padded in an infinitely large plane of zeros! $\endgroup$ – Marcus Müller Aug 9 at 9:27
  • $\begingroup$ I m not sure I understand what you mean. However, my question is: can you formulate mathematically what happends to the phase? I mean is a +theta angle added to it for example? $\endgroup$ – Machupicchu Aug 9 at 9:29
  • $\begingroup$ Not uniformly, no. I think this might help. Pad your image to all sides with say 10 times the image size of zeros. Apply the DFT; observe the effect of zero padding. Now cut the DFT to its original size, IDFT. Observe the aliasing you're getting. Now, experiment with rotations: Observe how the limitation to finite image sizes always leads to circular operations and aliasing. $\endgroup$ – Marcus Müller Aug 9 at 9:33

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.