图片的几何变换《07图片旋转》

图片的几何变换《07图片旋转》

代码

import cv2
import numpy as np

img = cv2.imread('1.jpg',1)
cv2.imshow('src',img)
imgInfo = img.shape
height = imgInfo[0]
width = imgInfo[1]
'''
我们使用getRotationMatrix2D()函数来完成图片的旋转操作。它有三个参数:
参数1:图片中心点
参数2:图片旋转角度
参数3:缩放比例
'''
matRotate = cv2.getRotationMatrix2D((height*0.5,width*0.5),45,0.5)    # 为方便旋转后图片能完整展示,所以我们将其缩小
dst = cv2.warpAffine(img,matRotate,(height,width))
cv2.imshow('image',dst)
cv2.waitKey(0)
发布了83 篇原创文章 · 获赞 25 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/Jamesaonier/article/details/105133197