Image Translation and Rotation
Discover what we can do with image translation and rotation.
To adjust images or rotate them for graphics designing and other purposes, we can use photo editing applications to edit them. However, if we have thousands of images to edit, it’ll take hours to edit them all. The OpenCV library provides image translation and rotation to solve this problem.
Create a translation matrix
To create a translation matrix, we use the float32()
method of the NumPy library. We use the following code to create a translation matrix:
translationMatrix = np.float32([[1, 0, x], [0, 1, y]])
Note: We need to import
np
first, which is the NumPy library.
Here, x
and y
are the important variables that determine the magnitude and direction of the translation of the image.
Get hands-on with 1400+ tech skills courses.