首页 > 其他 > 详细

图像仿射变换/旋转

时间:2019-09-03 14:20:01      阅读:95      评论:0      收藏:0      [点我收藏+]
import cv2
import numpy as np
img = cv2.imread(‘../img/zidan.jpg‘,1)
imgInfo = img.shape
height = 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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!