opencv图片移位

import numpy as np
img = cv2.imread("E:/code/conputer_visual/data/0.jpg", 1)
#显示原图像
cv2.imshow("src", img)
img_info = img.shape
height = img_info[0]
width = img_info[1]
#移位矩阵, 表示水平方向移动100像素,竖直方向移动50像素
mat_shift = np.float32([[1,0,100],[0,1,50]])
#移位原图像
dst = cv2.warpAffine(img, mat_shift, (height, width))
#显示移位的目标图像
cv2.imshow("dst", dst)
cv2.waitKey()

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/cyj5201314/article/details/113439892
今日推荐