Ask Your Question
3

Logical flaw in OpenCV 2.4.8 SIFT implementation?

asked 2014-03-02 20:50:23 -0600

researcholic gravatar image

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2014-03-13 07:09:16 -0600

Guanta gravatar image

I have no clue about this issue. However, since SIFT is a kinda state of the art descriptor, I justed wanted to raise attention to this post again. Taking the code snippet from above w. sigma = 1.5 and different nOctaveLayers, it results in:

nOctaveLayers = 2
sigma[0] 1.5
sigma[1] 1.5
sigma[2] 2.12132
sigma[3] 3
sigma[4] 4.24264

nOctaveLayers = 3
sigma[0] 1.5
sigma[1] 1.14963
sigma[2] 1.44844
sigma[3] 1.82493
sigma[4] 2.29926
sigma[5] 2.89689

nOctaveLayers = 4
sigma[0] 1.5
sigma[1] 0.965391
sigma[2] 1.14805
sigma[3] 1.36527
sigma[4] 1.62359
sigma[5] 1.93078
sigma[6] 2.2961

So, for nOctaveLayers = 2 you are right, but is it also wrong for higher Octavge-layers? And how is sigma then later used? Maybe s.o. else would like to dig in the code more and test if this is really a bug, or correct.

@researcholic: maybe you'd like to fill a bug-report at http://code.opencv.org/projects/OpenCV/wiki/WikiStart#Creating-new-tickets or better try first to verify the issue (maybe by comparison with other SIFT-libraries - e.g. the one of vlfeat) and then fix the bug and make a pull-request.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-03-02 20:50:23 -0600

Seen: 535 times

Last updated: Mar 13 '14