import cv2import numpy as npimg = cv2.imread(‘../img/zidan.jpg‘,1)imgInfo = img.shapeheight = imgInfo[0]width = imgInfo[1]matSrc = np.float32([[0,0],[0,height-1],[width-1,0]])#输入图像对应的三角形的顶点坐标matDst = np.float32([[50,50],[100,height-50],[width-200,100]])#输出图像对应的三角形顶点坐标matAff = cv2.getAffineTransform(matSrc,matDst)#由三对点计算仿射变换dst = cv2.warpAffine(img,matAff,(width,height))#对图像做仿射变换
matRotate = cv2.getRotationMatrix2D((height*0.5,width*0.5),45,0.5)#参数1:中心点 参数2:旋转角度 参数3:缩放程度dst = cv2.warpAffine(img,matRotate,(height,width))cv2.imshow(‘dst‘,dst) cv2.imshow(‘dst1‘,dst1)
cv2.waitKey(0)图像仿射变换效果图;
图像旋转效果图:
原文地址:https://www.cnblogs.com/cxxBoo/p/11452382.html
时间: 2024-10-07 07:16:07