我试图检测和匹配来自不同来源(以及不同的照明,对比度等)的同一场景的两组图像中的特征 .
目前我已经尝试了各种不同的特征检测/描述方法(SURF,SIFT,ORB)以及一些简单的预处理步骤(缩小图像,直方图均衡)而没有令人满意的结果 .
我正在使用比率测试或交叉检查以及单应性ransac的强力匹配器 . 但是,几乎在所有情况下我都没有(或很少)匹配 .

我可以做些什么预处理才能使图像更适合特征匹配?
哪种算法最适合这些条件?

这是两个示例图像:Image 1 Image 2

这是我到目前为止的代码:

import cv2
import matplotlib.pyplot as plt
import numpy as np


img1 = cv2.imread('test1.png', cv2.IMREAD_GRAYSCALE)
img2 = cv2.imread('test2.png', cv2.IMREAD_GRAYSCALE)


extended = False
hessian_threshold = 300
mask = None
d_lim = 100


surf = cv2.xfeatures2d.SURF_create(
    hessian_threshold,
    upright=True,
    extended=extended)
surf2 = cv2.xfeatures2d.SURF_create(
    hessian_threshold,
    upright=True,
    extended=extended)

kp1, des1 = surf.detectAndCompute(img1, mask)
kp2, des2 = surf2.detectAndCompute(img2, mask)
print("keypoints found:\nimg1:\t",
      len(kp1), "\nimg2:\t", len(kp2))


bf = cv2.BFMatcher(cv2.NORM_L2, True)
matches = bf.match(des1, des2)
print("bruteforce matches:\t\t", len(matches))

matches = sorted(matches, key=lambda x: x.distance)

better = []
for m in matches:
    if np.linalg.norm(
            np.array(kp1[m.queryIdx].pt) -
            np.array(kp2[m.trainIdx].pt)) < d_lim:
        better.append(m)
print("distance test matches:\t\t", len(better))

list1 = []
list2 = []

for match in better:
    ptr = (kp1[match.queryIdx].pt)
    list1.append(np.array(ptr))
    ptc2 = np.array(kp2[match.trainIdx].pt)
    list2.append(ptc2.reshape(2))

uv1 = np.array(list1)
uv2 = np.array(list2)

M, mask = cv2.findHomography(uv1, uv2, cv2.RANSAC, 5.0)
if mask is not None:
    uv1 = uv1[mask.flatten().astype('bool')]
    uv2 = uv2[mask.flatten().astype('bool')]
    print("homography test matches:\t", mask.sum())


plt.subplots(1, 2, figsize=(9, 9))
plt.subplot(1, 2, 1)
plt.imshow(img1, cmap='gray')
plt.scatter(uv1[:, 0], uv1[:, 1], marker='x', color='red', s=3)

plt.subplot(1, 2, 2)
plt.imshow(img2, cmap='gray')
plt.scatter(uv2[:, 0], uv2[:, 1], marker='x', color='red', s=3)

plt.show()

输出:

keypoints found:
img1:    3609
img2:    387
bruteforce matches:              202
distance test matches:           14
homography test matches:         6

在这里,2分似乎近似匹配,但其他'匹配'则没有 . (稍后删除异常值不是问题,只是没有任何其他候选者 . )

希望有人可以提供一些见解或者至少指出我相关文献的方向!
谢谢!