<p>Fourier transforms wouldn't help you with a rotation. You'd just end up having to rotate the matrix of Fourier coefficients, instead of rotating the original image.</p>

<p>Consider for example an image made of a perfect sine wave along the x-axis with wave-vector $(k, 0)$.  (The wave-vector is the spacial frequencies along the $x$ and $y$ axes).  The Fourier transform of this would be all black, with a single white pixel at position $(k, 0)$.</p>

<p>When you rotate the image by an angle $\theta$, you'll get a perfect sine wave along an oblique axis.  If you draw a diagram and do a little trigonometry, you can see that the new wave-vector will be $(k \cos \theta, k \sin \theta)$.  (It helps for this part to know that the frequency $k$ is one over the period.)</p>

<p>Therefore, the Fourier transform of the rotated result would be all black, with a single white pixel at position $(k \cos \theta, k \sin \theta)$.  But that's just what you'd get if you rotated the Fourier transform of the original wave by $\theta$.</p>

<p>As for the Gibbs phenomenon, it's an issue when downsampling an image, or compressing it by frequency quantization (as in JPEG). But simply taking the Fourier transform of an image doesn't introduce any Gibbs ringing. The Fourier transform is lossless and perfectly reversible if done properly: it represents all the information in the original image.</p>

CC BY-SA 3.0
2015-08-25T21:30:55.597Z
2015-11-03T19:15:29.400Z
2015-11-03T19:15:29.400Z
Nathan Reed
<p>Yes, it is possible.  Remember that a shift in space is equivalent to a linear-phase multiplication in frequency.  A rotation can be accomplished by a shearing operation in one direction followed by a shearing operation in the perpendicular direction followed by a final shear in the original direction (Alan Paeth, ``A Fast Algorithm for General Raster Rotation,'' Proceedings of Graphics Interface 1986.  Larkin et al. have shown how to take this concept and turn it into 1D FFTs multiplied by linear-phase terms, another set of perpendicular 1D FFTs followed by linear-phase multiplication, followed by a final set of 1D FFTs, etc., in the original direction ("Fast Fourier method for the accurate rotation of sampled images", Optic Communications, 1997).  </p>

<p>Alternately, you can definitely rotate the Fourier matrix to accomplish rotation.  But you have to keep in mind that the rotation must be around the origin in DFT space.  Since the DFT is periodic, you have to circularly shift the array to the center, rotate around that, and then shift back.  Even then it induces a rotation of the image around the origin (upper left corner), accounting for the fact that the image itself is now treated by the DFT as if it is periodic.</p>

CC BY-SA 3.0
2017-03-13T02:41:03.990Z
2017-03-13T02:41:03.990Z
Stan Reeves
<p>I'm not sure how practical this might be but is it possible to use Fast Fourier Transform to rotate a raster image?</p>

<p>To be honest, I never really understood FFT, but I saw it being used for JPEG, for example. What I try to say is let's pretend I can grab some FFT library, what do I do next?</p>

<p>Also, I read that there is this <a href="https://en.wikipedia.org/wiki/Gibbs_phenomenon" rel="noreferrer">Gibbs phenomenon</a> which causes ringing artifacts. Would it be a problem here as well?</p>

CC BY-SA 3.0
2015-09-11T08:33:51.733Z
_"I never really understood FFT, but I saw it being used for JPEG"_.  I'm not sure exactly what you meant by this, but FWIW, JPEG doesn't use FFT. Instead it uses a different transform, the Discrete Cosine Transform (DCT).  The DCT has some advantages over the FFT in that, although they both repeat ad infinitum, the DCT reflects at each repetition which thus implies better continuity.
Simon F
CC BY-SA 3.0
2015-09-11T09:19:07.820Z
@SimonF You see, I even thought DCT is a special case of FFT. Thanks for clarification!
Ecir Hana
<transformations><fourier-transform><raster-image>
Image rotation using FFT
Ecir Hana
# Image rotation using FFT

(Asked by: username_0 on 2015-08-25)

I'm not sure how practical this might be but is it possible to use Fast Fourier Transform to rotate a raster image?

To be honest, I never really understood FFT, but I saw it being used for JPEG, for example. What I try to say is let's pretend I can grab some FFT library, what do I do next?

Also, I read that there is this [Gibbs phenomenon](https://en.wikipedia.org/wiki/Gibbs_phenomenon) which causes ringing artifacts. Would it be a problem here as well?

**Tags:** transformations, fourier-transform, raster-image

> **Comments:**
> **username_1**: _"I never really understood FFT, but I saw it being used for JPEG"_.  I'm not sure exactly what you meant by this, but FWIW, JPEG doesn't use FFT. Instead it uses a different transform, the Discrete Cosine Transform (DCT).  The DCT has some advantages over the FFT in that, although they both repeat ad infinitum, the DCT reflects at each repetition which thus implies better continuity.  
> **username_0**: @username_1 You see, I even thought DCT is a special case of FFT. Thanks for clarification!  

---

## 2 answers

### Answer by username_2 on 2015-08-25. Score: 8 | Accepted answer

Fourier transforms wouldn't help you with a rotation. You'd just end up having to rotate the matrix of Fourier coefficients, instead of rotating the original image.

Consider for example an image made of a perfect sine wave along the x-axis with wave-vector $(k, 0)$. (The wave-vector is the spacial frequencies along the $x$ and $y$ axes). The Fourier transform of this would be all black, with a single white pixel at position $(k, 0)$.

When you rotate the image by an angle $\theta$, you'll get a perfect sine wave along an oblique axis. If you draw a diagram and do a little trigonometry, you can see that the new wave-vector will be $(k \cos \theta, k \sin \theta)$. (It helps for this part to know that the frequency $k$ is one over the period.)

Therefore, the Fourier transform of the rotated result would be all black, with a single white pixel at position $(k \cos \theta, k \sin \theta)$. But that's just what you'd get if you rotated the Fourier transform of the original wave by $\theta$.

As for the Gibbs phenomenon, it's an issue when downsampling an image, or compressing it by frequency quantization (as in JPEG). But simply taking the Fourier transform of an image doesn't introduce any Gibbs ringing. The Fourier transform is lossless and perfectly reversible if done properly: it represents all the information in the original image.


---

### Answer by username_3 on 2017-03-13. Score: 4

Yes, it is possible. Remember that a shift in space is equivalent to a linear-phase multiplication in frequency. A rotation can be accomplished by a shearing operation in one direction followed by a shearing operation in the perpendicular direction followed by a final shear in the original direction (Alan Paeth, ``A Fast Algorithm for General Raster Rotation,'' Proceedings of Graphics Interface 1986. Larkin et al. have shown how to take this concept and turn it into 1D FFTs multiplied by linear-phase terms, another set of perpendicular 1D FFTs followed by linear-phase multiplication, followed by a final set of 1D FFTs, etc., in the original direction ("Fast Fourier method for the accurate rotation of sampled images", Optic Communications, 1997).

Alternately, you can definitely rotate the Fourier matrix to accomplish rotation. But you have to keep in mind that the rotation must be around the origin in DFT space. Since the DFT is periodic, you have to circularly shift the array to the center, rotate around that, and then shift back. Even then it induces a rotation of the image around the origin (upper left corner), accounting for the fact that the image itself is now treated by the DFT as if it is periodic.


---

