1.垂直影像拼接 vconcat
# -*- coding: utf-8 -*-
import cv2
image = cv2.imread("lena.jpg")
image_v = cv2.vconcat([image, image])
cv2.imshow("Result", image_v)
cv2.waitKey(0)
样式:
2.水平影像拼接 hconcat
# -*- coding: utf-8 -*-
import cv2
image = cv2.imread("lena.jpg")
image_h = cv2.hconcat([image, image])
cv2.imshow("Result", image_h)
cv2.waitKey(0)
样式:
3.纵向拼接多个不同图片
import cv2
img = cv2.imread('icon/big.jpg')
img2=cv2.imread("icon/small.jpg")
def vconcat_resize_min(im_list, interpolation=cv2.INTER_CUBIC):
w_min = min(im.shape[1] for im in im_list)
im_list_resize = [cv2.resize(im, (w_min, int(im.shape[0] * w_min / im.shape[1])), interpolation=interpolation)
for im in im_list]
return cv2.vconcat(im_list_resize)
im_v_resize = vconcat_resize_min([img, img2])
cv2.imwrite('opencv_vconcat_resize.jpg', im_v_resize)
到此这篇关于python opencv实现影像拼接的文章就介绍到这了,更多相关 opencv影像拼接内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!