我使用python3.5和opencv来缝合图像。图像的尺寸是1920 X 1080。到目前为止,我已经使用了SIFT和ORB,任何缝合的迹象都只能在SIFT和{}中看到,我要么得到训练图像,要么得到一个非常扭曲的图像。。在
实际的图像拼接是根据这本书OpenCV with Python by Example实现的。这似乎是使用python和opencv拼接图像的标准方法,正如在这里和网上看到的各种帖子一样。在
这是缝合图像的代码def warpImages(train_img , query_img , H):
# This function waprs query image to train image
t_row , t_col = train_img.shape[: 2]
q_row , q_col = query_img.shape[: 2]
list_pts1 = np.float32([[0 , 0] , [0 , t_row] , [t_col , t_row] , [t_col , 0]]).reshape(-1 , 1 , 2)
temp_points = np.float32([[0 , 0] , [0 , q_row] , [q_col , q_row] , [q_col , 0]]).reshape(-1 , 1 , 2)
list_pts2 = cv2.perspectiveTransform(temp_points , H)
list_pts = np.concatenate((list_pts1 , list_pts2) , axis = 0)
[x_min , y_min] = np.int32(list_pts.min(axis = 0).ravel() - 0.5)
[x_max , y_max] = np.int32(list_pts.max(axis = 0).ravel() + 0.5)
print(x_max , x_min)
print(y_max , y_min)
translation_dist = [-x_min , -y_min]
H_translation = np.array([[1 , 0 , translation_dist[0]] , [0 , 1 , translation_dist[1]] , [0 , 0 , 1]])
output_img = cv2.warpPerspective(query_img , H_translation.dot(H) , (x_max - x_min , y_max - y_min))
output_img[translation_dist[1] : t_row + translation_dist[1] , translation_dist[0] : translation_dist[0] + t_col ] = train_img
return output_img
这是为了找到Homography Matrix and Features。在
^{pr2}$
从上面的代码中可以看出,我已经注释了ORB和{},因为结果图像没有缝合。'SIFT'给了我一个不太准确的结果,也占用了时间来处理,这是可以理解的。在
以下是使用的图像:
查询图像:
列车图像
使用SIFT的结果图像
使用结果
可以看出ORB给出了一个错误的结果,在SIFT中,它看起来像是一个重复的模式。ORB的速度更快。我在这里引用了以下帖子:
^{{a8}这里的{a8}不适合拼接}图像。在
我是新的图像缝合,真的希望一些关于如何处理和处理这一点的建议。在
更新
添加匹配特征图