Created
March 15, 2019 05:49
-
-
Save ChongyeWang/aa00c90832d457fdaacf2addaed586c4 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') | |
height, width = image.shape[:2] | |
# Divide by two to rototate the image around its centre | |
rotation_matrix = cv2.getRotationMatrix2D((width/2, height/2), 90, .5) | |
rotated_image = cv2.warpAffine(image, rotation_matrix, (width, height)) | |
cv2.imshow('Rotated Image', rotated_image) | |
cv2.waitKey() | |
cv2.destroyAllWindows() | |
# Other Option to Rotate | |
img = cv2.imread('images/input.jpg') | |
rotated_image = cv2.transpose(img) | |
cv2.imshow('Rotated Image - Method 2', rotated_image) | |
cv2.waitKey() | |
cv2.destroyAllWindows() | |
# Let's now to a horizontal flip. | |
flipped = cv2.flip(image, 1) | |
cv2.imshow('Horizontal Flip', flipped) | |
cv2.waitKey() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment