【问题标题】:How does vl_ubcmatch work technically?vl_ubcmatch 在技术上是如何工作的?
【发布时间】:2012-12-01 15:55:58
【问题描述】:

我正在阅读 vl_ubcmatch 的函数源代码,提供here,并试图了解它是如何计算分数的,以及它在技术上是如何工作的。

但是,这个 C 代码有这些宏、奇怪的 ## 变量之类的,以及其他我没有经验的东西。所以这里的主要问题是我在 C 方面的无能。如果可能的话,有人能告诉我,vl_ubcmatch 是如何工作的吗?它如何比较两个描述符?

【问题讨论】:

标签: c sift vlfeat


【解决方案1】:

Distinctive Image Features from Scale-Invariant Keypoints 的第 7.1 和 7.2 节对此进行了解释。

函数的文档在这里:http://www.vlfeat.org/mdoc/VL_UBCMATCH.html

仅当 d1 和 d2 之间的距离明显小于到 d1 和图像 2 中任何其他特征的距离时,才使用从图像 1 中的特征 d1 到图像 2 中的特征 d2 的匹配。匹配需要明显更好比任何其他潜在的匹配。 “显着”由您传递给 VL_UBCMATCH 函数的阈值定义。

第 7.2 节提到了一个近似的最近邻搜索结构,但 VL_UBCMATCH 没有使用这个:

for(k1 = 0 ; k1 < K1 ; ++k1, L1_pt += ND ) {                        \
                                                                    \
  PROMOTE_##MXC best = maxval ;                                     \
  PROMOTE_##MXC second_best = maxval ;                              \
  int bestk = -1 ;                                                  \
                                                                    \
  /* For each point P2[k2] in the second image... */                \
  for(k2 =  0 ; k2 < K2 ; ++k2, L2_pt += ND) {                      \
                                                                    \
    int bin ;                                                       \
    PROMOTE_##MXC acc = 0 ;                                         \
    for(bin = 0 ; bin < ND ; ++bin) {                               \
      PROMOTE_##MXC delta =                                         \
        ((PROMOTE_##MXC) L1_pt[bin]) -                              \
        ((PROMOTE_##MXC) L2_pt[bin]) ;                              \
      acc += delta*delta ;                                          \
    }                                                               \
                                                                    \
    /* Filter the best and second best matching point. */           \
    if(acc < best) {                                                \
      second_best = best ;                                          \
      best = acc ;                                                  \
      bestk = k2 ;                                                  \
    } else if(acc < second_best) {                                  \
      second_best = acc ;                                           \
    }                                                               \
  }                                                                 \
                                                                    \
  L2_pt -= ND*K2 ;                                                  \
                                                                    \
  /* Lowe's method: accept the match only if unique. */             \
  if(thresh * (float) best < (float) second_best &&                 \
     bestk != -1) {                                                 \
    pairs_iterator->k1 = k1 ;                                       \
    pairs_iterator->k2 = bestk ;                                    \
    pairs_iterator->score = best ;                                  \
    pairs_iterator++ ;                                              \
  }                                                                 \
}

这是伪代码:

matches = []
For each descriptor k1 in image 1:
    closest_match_distance = Infinity
    second_closest_match_distance = Infinity
    best_match = None
    For each descriptor k2 in image 2:
        distance_squared = d(k1, k2)
        if (distance_squared < closest_match_distance):
            second_closest_match_distance = closest_match_distance
            closest_match_distance = distance_squared
            best_match = k2
    If (threshold * closest_match_distance <
      second_closest_match_distance AND best_match != None):
        matches.Insert((k1, best_match, closest_match_distance))
return matches

【讨论】:

    猜你喜欢
    • 2011-08-04
    • 2011-03-05
    • 2016-07-12
    • 2011-04-05
    • 2015-03-09
    • 1970-01-01
    • 2011-07-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多