next up previous
Next: About this document ... Up: resize Previous: Arbitrary resizing

Arbitrary rotation

We first note that rotating the input image $x$ by an angle $\phi$ is equivalent to rotating the output image $y$ by an angle $-\phi$. For the indices $(k,l)$ of each pixel in the output $y$ we find the corresponding position in the input $x$:

\begin{displaymath}
\left\{ \begin{array}{l}
p=\;\;\;\cos(\phi) k+\sin(\phi) l \\
q=-\sin(\phi) k+\cos(\phi) l \end{array} \right.
\end{displaymath}

This rotation is about the origin of the image, the top left corner of the image. If we want the rotation to be around the center $(x0=M/2,\;y0=N/2)$ of an image of size $M\times N$, then

\begin{displaymath}
\left\{ \begin{array}{l}
p=[\;\;\;\cos(\phi) (k-x0)+\sin(\p...
...-\sin(\phi) (k-x0)+\cos(\phi) (l-y0)]+y0
\end{array} \right.
\end{displaymath}

Next we find the interpolation value $x_{p,q}$ for each pixel $y_{k,l}$ of the output image using the same bilinear interpolation method as in the arbitrary scaling discussed above. Note that some pixels in the image after the rotation may be outside the original image before the rotation, they can be arbitrarily assigned with any color, such as black.

ImageRotate1.gif

LennaRotate.gif



Ruye Wang 2014-09-12