利用python语言实现多张图像拼接_小饼干cookie的博客-CSDN博客_python拼接图像
主要参考上述博文,只是对于复现过程遇到的小问题的解决做一些补充。
拼接程序:
from pylab import *
from numpy import *
from PIL import Image
# If you have PCV installed, these imports should work
from PCV.geometry import homography, warp
from PCV.localdescriptors import sift
"""
This is the panorama example from section 3.3.
"""
featname = ['D:/pythonCode/test/data/testimages/' + str(i + 1) + '.sift' for i in range(5)] //需要根据自己的图像地址和图像数量修改地址和循环次数
imname = ['D:/pythonCode/test/data/testimages/' + str(i + 1) + '.jpg' for i in range(5)]
# extract features and m
# match
l = {}
d = {}
for i in range(5): //循环次数=图像数量
sift.process_image(imname[i], featname[i])
l[i], d[i] = sift.read_features_from_file(featname[i])
matches = {}
for i in range(4): //循环次数=图像数量-1
matches[i] = sift.match(d[i + 1], d[i])
# visualize the matches (Figure 3-11 in the book)
for i in range(4): //循环次数=图像数量-1
im1 = array(Image.open(imname[i]))
im2 = array(Image.open(imname[i + 1]))
figure()
sift.plot_matches(im2, im1, l[i + 1], l[i], matches[i], show_below&#