[[A1 A2 B1],[A3 A4 B2]] #先定义矩阵
[[A1 A2],[A3 A4]] [[B1],[B2]] #将定义好的矩阵拆分
newX = A1x + A2y+B1 #计算新的xy
newY = A3x +A4y+B2x->x0.5 y->y0.5 #缩放一半
newX = 0.5*x
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]
matScale = np.float32([[0.5,0,0],[0,0.5,0]]) #定义缩放矩阵
dst = cv2.warpAffine(img,matScale,(int(width/2),int(height/2))) #用于保存最终的定义图片
cv2.imshow('dst',dst)
cv2.waitKey(0)
网友评论