本文共 420 字,大约阅读时间需要 1 分钟。
import cv2import numpy as npimg1 = cv2.imdecode(np.fromfile('./zly.jpg', dtype=np.uint8), -1)img2 = cv2.imdecode(np.fromfile('./yx.jpg', dtype=np.uint8), -1)# 纵向合并img_zhong = np.vstack((img1, img2))# axis=1:横向合并 axis=0 纵向合并img_heng = np.concatenate([img1, img2], axis=1)cv2.imshow('img_zhong', img_zhong)cv2.imshow('img_heng', img_heng)cv2.waitKey(0)
此类拼接,大小得对应才可以。
img1: img2:横向拼接结果:
纵向拼接结果:
转载地址:http://ifhof.baihongyu.com/