1、原理
1、图像拼接的关键两步是:配准(registration)和融合(blending)。配准的目的是根据几何运动模型,将图像注册到同一个坐标系中;融合则是将配准后的图像合成为一张大的拼接图像。图像的平移模型是指图像仅在两维空间发生了 方向和 方向的位移,如果摄像机仅仅发生了平移运动,则可以采用平移模型。
2、图像拼接主要有以下几个步骤:
(1) 读入图片,利用SIFT特征自动找到匹配对应。
(2) 使用RANSAC算法求解单应性矩阵
(3) 将所有的图像扭曲到一个公共的图像平面上。
(4) 进行图像融合。
2、代码
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.
"""
# set paths to data folder
featname = ['D:/photo/pingjie2/inside'+str(i+1)+'.sift' for i in range(5)]
imname = ['D:/photo/pingjie2/inside'+str(i+1)+'.jpg' for i in range(5)]
# extract features and match
l = {
}
d = {
}
for i in range(5):
sift.process_image(imname[i], featname[i])
l[i], d[i]</