目录
一、旋转矩阵 cv2.getRotationMatrix2D()
一、旋转矩阵 cv2.getRotationMatrix2D()
这个函数需要三个参数
- 旋转中心
- 旋转角度
- 旋转后图像的缩放比例
rotate = cv2.getRotationMatrix2D((x/2,y/2),45,0.5)
二、warpAffine()
res = cv2.warpAffine(img1,rotate,(0.5*x,0.5*y))
三、代码
import cv2
img1 = cv2.imread('./Image/reba_color.jpg',cv2.IMREAD_COLOR)
x,y = img1.shape[:2]
rotate = cv2.getRotationMatrix2D((x/2,y/2),45,0.5)
res = cv2.warpAffine(img1,rotate,(0.5*x,0.5*y))
cv2.imshow('img',img1)
cv2.imshow('res',res)
cv2.waitKey(0)