Python - 使用特征向量匹配关键点

问题描述 投票:0回答:1

我试图使用特征向量和欧氏距离作为相似度测量来匹配2个网格的关键点。

我尝试的,这里是一个简单的例子,我做了一个主数据的例子。

a = [0,1,4,6]
    fv_a = [[2.1,4],
            [0.7,3.1],
            [2.23,6],
            [0,1.11]]
    b = [1,3,0,4]
    fv_b = [[0.7,3.1],
            [4.1,3.3],
            [2.1,4],
            [2.23,6]]
    fv_a = (fv_a - np.min(fv_a)) / np.ptp(fv_a)
    fv_b = (fv_b - np.min(fv_b)) / np.ptp(fv_b)
    distances = scipy.spatial.distance.cdist(fv_a,fv_b)
    print(distances)
    # print(np.amax(distances,1))
    # print(np.argmax(distances,1))
    matched = np.argmax(distances,1)
    print(matched)
    for i,j in enumerate(matched):
        print(i, "linked to : ",j)
        print("point in a",a[i]," is matched to: ",b[j])

所以重点是,对于每一个点 a 我有一个它的特征向量,用以下方式表示 fv_a 我想把它和 b

但结果是这样的。

 [0.1329895  0.52549136 0.18161024 0.51302967]
 [0.6614612  0.57648771 0.39237617 0.08298742]
 [0.26783019 0.71056665 0.5111808  0.86461593]]
[0 1 0 3]
0 linked to :  0
point in a 0  is matched to:  1
1 linked to :  1
point in a 1  is matched to:  3
2 linked to :  0
point in a 4  is matched to:  1
3 linked to :  3
point in a 6  is matched to:  4

这是不正确的,因为0应该匹配0,1应该匹配1,等等... ...

请问我做错了什么?

是的,我正在尝试做 一对一. 有什么好的建议吗?

python matrix matching feature-extraction
1个回答
0
投票

使用 Scikit图书馆 做到了。

这个功能让我得到我需要的东西:)

from skimage.feature import match_descriptors
© www.soinside.com 2019 - 2024. All rights reserved.