Created
March 15, 2019 05:47
-
-
Save ChongyeWang/dc42aff02c0d257ae2da8b5cecb37bb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
image = cv2.imread('images/input.jpg') | |
# Store height and width of the image | |
height, width = image.shape[:2] | |
quarter_height, quarter_width = height/4, width/4 | |
# | 1 0 Tx | | |
# T = | 0 1 Ty | | |
# T is our translation matrix | |
T = np.float32([[1, 0, quarter_width], [0, 1,quarter_height]]) | |
# We use warpAffine to transform the image using the matrix, T | |
img_translation = cv2.warpAffine(image, T, (width, height)) | |
cv2.imshow('Translation', img_translation) | |
cv2.waitKey() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment