# Advanced Object Marker ::: [Rotating Images (Rotation and Scaling)]

So initially we thought to rotate the image 1 degree and save the resulting image, we then ended up with about 360 image files derived from a single image. If we marked just the initial image (non-rotated) then based off of the placement in that image we could derive the position of interest in all subsequent images. With this technique there were a few problems encountered.
Below is an example of the images and their rotation. You will notice that along with the rotation there was also significant scaling to the image. So not only would we have to derive the position from the rotation but also the scaling.

So, I decided to simplify the situation and alleviate the scaling portion and only focus on the rotation. Below is a code excerpt that rotates an image about the center point and also keeps the original scale. Which is fortunate in our case that our images do not contain any useful information on the edges of the frame so if we lose the edges it does not hurt our purposes at all since its just black space.

```//!****************************************************************
//! @details
//! This method rotates an image by a angle (degree) value
//!
//! @param [in,out] const Mat& source
//! The Mat image to rotate
//!
//! @param [in] double angle
//! The angle (degree) of rotation
//!
//! @return Mat dst
//! The resultant destination image after rotation
//!****************************************************************
Mat RotateImage(const Mat& source, double angle)
{
//Get the center point of the image
Point2f src_center(source.cols/2.0F, source.rows/2.0F);
Mat rotation_matrix = getRotationMatrix2D(src_center, angle, 1.0);

//Show the rotation matrix
//cvNamedWindow( "Rotation Matrix", CV_WINDOW_NORMAL );
//imshow("Rotation Matrix", rotation_matrix);
//waitKey(0);
//cvDestroyWindow("Rotation Matrix");

Mat dst;
warpAffine(source, dst, rotation_matrix, source.size());
return dst;
}
```

Below is an example of the images and their rotation. You will notice that along with the rotation there was no significant scaling to the image. So we no longer have to derive the position of the region based on the rotation and scaling.