python opencv实现影像拼接
时间:2022-06-14 10:11:25|栏目:Python代码|点击: 次
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灰色预测法的具体使用
栏 目:Python代码
本文标题:python opencv实现影像拼接
本文地址:http://www.codeinn.net/misctech/204804.html