Image Translation and Rotation

Discover what we can do with image translation and rotation.

Sometimes we want to change the position of an image or rotate it while doing graphic design. We might use photo editing tools when we have just a few images to edit. However, if we have thousands of images to edit, it’ll take hours to edit them all. So the solution is to use image translation and rotation in the OpenCV library. Image translation and rotation fall under the class of affine transformations.

Creating a translation matrix

The translation of an image in OpenCV is shifting the image by certain pixels in the horizontal and vertical direction. We need to specify the translation matrix through which the translation of the image is to occur. If we want to shift the image xx pixels along the horizontal and yy pixels along the vertical, the translation matrix would be:

Get hands-on with 1200+ tech skills courses.