Translation refers to the rectilinear shift of an object i.e. an image from one location to another. If we know the amount of shift in horizontal and the vertical direction, say (tx, ty) then we can make a transformation matrix e.g.
where tx denotes the shift along the x-axis and ty denotes shift along the y-axis i.e. the number of pixels by which we need to shift about in that direction.
Now, we can use the
cv2.wrapAffine() function to implement these translations. This function requires a 2×3 array. The numpy array should be of float type.
Below is the Python code for Image Translation:
Advantages/application of image translation are:
- Hiding a part of the image
- Cropping an image
- Shifting an image
- Animating an image using image translations in loop.
- Image Pyramid using OpenCV | Python
- Python | Image blurring using OpenCV
- Log transformation of an image using Python and OpenCV
- Cartooning an Image using OpenCV - Python
- Image Registration using OpenCV | Python
- Reading an image in OpenCV using Python
- Image Resizing using OpenCV | Python
- Image Processing without OpenCV | Python
- Image Steganography using OpenCV in Python
- OpenCV Python Program to blur an image
- Python | Detect corner of an image using OpenCV
- Negative transformation of an image using Python and OpenCV
- Python | Detect Polygons in an Image using OpenCV
- Python | OpenCV program to read and save an Image
- Find Circles and Ellipses in an Image using OpenCV | Python
- OpenCV Python Program to analyze an image using Histogram
- Set Countdown timer to Capture Image using Python-OpenCV
- Create Local Binary Pattern of an image using OpenCV-Python
- Python Program to detect the edges of an image using OpenCV | Sobel edge detection method
- Point Processing in Image Processing using Python-OpenCV
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.