OpenCV调整图像大小和旋转图像
调整图像大小
import numpy as np
import cv2
img = cv2.imread("cat.jpg", 1)
height, width = img.shape[:2]
res = cv2.resize(img, (int(width/2), int(height/2)),
interpolation = cv2.INTER_AREA)
cv2.imshow("image", res)
cv2.waitKey(0)
cv2.destroyAllWindows()
旋转图像
import numpy as np
import cv2
img = cv2.imread("cat.jpg", 1)
height, width = img.shape[:2]
center = (width / 2, height / 2);
mat = cv2.getRotationMatrix2D(center, 90, 1)
rotimg = cv2.warpAffine(img, mat, (height, width))
cv2.imshow("original", img)
cv2.imshow("rotated", rotimg)
cv2.waitKey(0)
cv2.destroyAllWindows()