图像仿射变换/旋转

安稳与你 提交于 2019-11-29 04:25:20
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)图像仿射变换效果图;

 

 图像旋转效果图:

 

 

 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!