import cv2 as cv import numpy as np # 图片移位 img = cv.imread('../images/moon.jpg', flags=1) # flags=1读取为彩色,flags=0读取为灰度 h, w = img.shape[:2] mat_shift = np.float32([[1, 0, 100], [0, 1, 200]]) # 移位矩阵,相当于沿x轴平移100,沿y轴平移200 dst = cv.warpAffine(img, mat_shi