美文网首页
08仿射变换

08仿射变换

作者: 犬夜叉写作业 | 来源:发表于2019-07-14 12:42 被阅读0次
image.png
import cv2
import numpy as np
img = cv2.imread('image0.jpg',1)
cv2.imshow('src',img)
imgInfo = img.shape
height = imgInfo[0]
width = imgInfo[1]
#原理:把原图像的3个点映射到目标矩阵三个新的位置上
#src 3->dst 3 (左上角 左下角 右上角)


matSrc = np.float32([[0,0],[0,height-1],[width-1,0]])   #描述原图片上的三个点
matDst = np.float32([[50,50],[300,height-200],[width-300,100]])  #映射到新位置
#组合
matAffine = cv2.getAffineTransform(matSrc,matDst)# mat 1 src 2 dst
dst = cv2.warpAffine(img,matAffine,(width,height))
cv2.imshow('dst',dst)
cv2.waitKey(0)

相关文章

网友评论

      本文标题:08仿射变换

      本文链接:https://www.haomeiwen.com/subject/elpbkctx.html