import cv2
import numpy as np
img = cv2.imread('ruonan.jpg')
Info = img.shape
height = Info[0]
width = Info[1]
matSrc = np.float32([[0,0],[0,height-1],[width-1,0]]) #左上,左下,右上坐标
matDst = np.float32([[50,50],[80,height-100],[width-50,100]]) #变换后的左上,左下,右上坐标
matAffine = cv2.getAffineTransform(matSrc,matDst) ##获得仿射变换矩阵
dst = cv2.warpAffine(img,matAffine,(width,height)) #参数1 原始图片 参数2 放射变换矩阵 参数3 仿射变换后的图像的宽度和高度
cv2.imshow('ORI',img)
cv2.imshow("desImg",dst)
cv2.waitKey(0)
14_图片的仿射变换
最新推荐文章于 2023-08-31 10:39:04 发布