简体   繁体   English

SIFT特征描述符的实现

[英]SIFT feature descriptor implementation

According to Lowe's paper about the original SIFT algorithm, a feature descriptor consisting of 4 x 4 orientation histograms is calculated from a 16 x 16 window. 根据Lowe关于原始SIFT算法的论文,从16 x 16的窗口计算出包含4 x 4方向直方图的特征描述符。 The scale of the descriptor is only used to select the level of gaussian blur for the image. 描述符的比例仅用于选择图像的高斯模糊水平。

Looking at the OpenCV implementation, this doesn't seem to be the case. 查看OpenCV的实现,情况似乎并非如此。 In calcSIFTDescriptor there is the following code to calculate the histograms: calcSIFTDescriptor有以下代码来计算直方图:

for( k = 0; k < len; k++ )
{
  // histogram update
}

Where len is the number of samples used. 其中len是使用的样本数。 According to Lowe's algorithm, this should always be 256 (16 x 16), shouln't be? 根据Lowe的算法,应该始终为256(16 x 16),不是吗? In OpenCV implementation the len depends on the scale of the descriptor. 在OpenCV实现中, len取决于描述符的大小。

Could someone clarify this? 有人可以澄清一下吗?

Thanks 谢谢

You're not looking at the code that builds the histogram but at the code that explores the neighbourhood of a given pixel to compute the gradient orientation and norm. 您不是在查看构建直方图的代码,而是在探索给定像素的邻域以计算梯度方向和范数的代码。

The relevant code is below in the source file: 相关代码在源文件中:

for( k = 0; k < len; k++ )
{
  int bin = cvRound((n/360.f)*Ori[k]);
  if( bin >= n )
    bin -= n;
  if( bin < 0 )
    bin += n;
  temphist[bin] += W[k]*Mag[k];
}

In this excerpt, the line cvRound(...) is the one that computes the target bin in the 16-bin histogram. 在此摘录中,线cvRound(...)是用于计算16格直方图中的目标格的行。

Normally, in SIFT you should first resample the feature point neighbourhood by recreating a grid of 4x4 blocks of 4x4 pixels. 通常,在SIFT中,您应该首先通过重新创建4x4像素的4x4块的网格来重新采样特征点邻域。 The code that you've shown is used to compute the gradient statistics without having to resample the image. 您显示的代码用于计算梯度统计信息,而无需重新采样图像。 The variable radius is here to take into account the image location in the scale space. 此处,可变半径要考虑图像在比例空间中的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM