尊师:
© Fu Xianjun. All Rights Reserved.
如何使用OpenCV实现图像的拼接
import cv2
import numpy as np
#先进行导包
a = cv2.imread(“A.jpg”)
a = cv2.resize(a,(512,512))
cv2.imshow(“a”,a)
b = cv2.imread(“B.jpg”)
b = cv2.resize(b,(512,512))
cv2.imshow(“b”,b)
#读取并显示两张帅哥图片
g = a.copy() #复制图像
gpa = [g]#定义列表存储图像变量
for i in range(5):#循环五次
g= cv2.pyrDown(g)#下采样
gpa.append(g)#将下列采样图像变量结果存入列表gpa
g = b.copy()#复制图像
gpb = [g]
for i in range(5):
g = cv2.pyrDown(g)
gpb.append(g)
#将采样图像变量结果存入列表gpb
lpa = [gpa[5]]