图片的仿射变换

实现图片仿射变换代码如下:

import cv2
import numpy as np
img = cv2.imread('image1.jpg',1)
imgInfo = img.shape
height = imgInfo[0]
width = imgInfo[1]
#src 3-> dst 3(左上角 左下角 右上角)
matSrc = np.float32([[0,0,],[0,height-1],[width-1,0]])
matDst = np.float32([[50,50],[300,height-300],[width-300,100]])
#组合
matAffine = cv2.getAffineTransform(matSrc,matDst)
dst = cv2.warpAffine(img,matAffine,(width,height))
cv2.imshow('dst',dst)
cv2.waitKey(0)

实现效果图如下:
在这里插入图片描述

发布了25 篇原创文章 · 获赞 2 · 访问量 400

猜你喜欢

转载自blog.csdn.net/yuan_xiangjun/article/details/105584619