In this section, we will discuss about shifting an image. Let's say we want to move the image within our frame of reference. In computer vision terminology, this is referred to as
translation. Let's go ahead and see how we can do that:
import cv2 import numpy as np img = cv2.imread('images/input.jpg') num_rows, num_cols = img.shape[:2] translation_matrix = np.float32([ [1,0,70], [0,1,110] ]) img_translation = cv2.warpAffine(img, translation_matrix, (num_cols, num_rows)) cv2.imshow('Translation', img_translation) cv2.waitKey()
If you run the preceding code, you will see something like the following:
To understand ...