#完成图像的旋转 import cv2 import numpy as np img = cv2.imread('image0.jpg', 1) imgInfo = img.shape height = imgInfo[0] width = imgInfo[1] #定义图像的旋转矩阵,参数1,旋转的中心点,2,旋转的角度,3,缩放的系数 matRotate = cv2.getRotationMatrix2D((height*0.5,width*0.5),45,0.5) #100*100旋转后——>为了防止旋转后角超出原图范围,所以进行缩放 #调用仿射方法,1、图片信息2、旋转矩阵3、图片宽高 dst = cv2.warpAffine(img,matRotate,(height,width)) #不进行缩放系数设置,会超出原图范围 cv2.imshow('dst',dst) cv2.waitKey(0)
图片处理:完成图片的旋转
最新推荐文章于 2023-01-10 10:45:33 发布