Ask Your Question

Revision history [back]

Logical flaw in OpenCV 2.4.8 SIFT implementation?

Hi everyone, I was reading the code on SIFT implementation in OpenCV 2.4.8 and found something I feel sceptical about. In the nonfree model, sift.cpp file, SIFT::buildGaussianPyramid method, the part where the sigma values are calculated by:

sig[0] = sigma;
double k = pow( 2., 1. / nOctaveLayers );
for( int i = 1; i < nOctaveLayers + 3; i++ )
{
    double sig_prev = pow(k, (double)(i-1))*sigma;
    double sig_total = sig_prev*k;
    sig[i] = std::sqrt(sig_total*sig_total - sig_prev*sig_prev);
}

however I tested the logic by using nOctaveLayers = 2 (which is chosen for the ease of calculation), the result of the sigma values are listed below according to the logic of the code:

  • sig[0] = sigma
  • sig[1] = sigma
  • sig[2] = sqrt(2)*sigma
  • sig[3] = 2*sigma
  • sig[4] = 2* sqrt(2)*sigma

But shouldn't it be:

  • sig[0] = sigma
  • sig[1] = sqrt(2)*sigma
  • sig[2] = 2*sigma
  • sig[3] = 2* sqrt(2)*sigma
  • sig[4] = 4*sigma

In order to make sure my understanding is correct, I looked up some lecture notes, it turns out my understanding is correct according to this link: SIFT lecture note from Berkley

Any suggestions? Maybe I should report a bug but I think I should seek confirmation here first. Thank you all.