SIFT implementation in openCV

Hi, I' ve tried to understand sift implementation in opencv. In sift.cpp class there is 'calcSIFTDescriptor' method; here, there are two for cycles: for( i = 0; i < d+2; i++ ) {...} and for( i = -radius, k = 0; i <= radius; i++ ) {...}. What is their meaning? Also, do you know some web sites or some documents that explain (better than openCV tutorial or refman) how sift algorithm in opencv works?

edit retag close merge delete

1
( 2016-12-03 06:23:22 -0500 )edit
1

To understand the method before the implementation: Distinctive Image Features from Scale-Invariant Keypoints, Wikipedia, etc.

( 2016-12-03 16:56:34 -0500 )edit

Sort by ยป oldest newest most voted

Well the first loop for( i = 0; i < d+2; i++ ) {...} is used, to fill the Histogramm of the descriptor where d is the width of the descriptor + 2 (e.g. with the 128 elements vector 4 + 2). It is initially filled with zeroes, so it would not occur the possibility, that a histogram bin would point to null instead of a value.

The second loop for( i = -radius, k = 0; i <= radius; i++ ) {...} is used pick the pixel values around the certain keypoint and to calculate the orientation and magnitude of it. The radius value determines what size this window where pixels will be looked up have. e.g. if radius is 15 the algorithms lookup window of the KeyPoint 100,100 would be a rectangle with the upperLeft and bottomRight coordinates 85, 85 and 115, 115

If you still don't know what is meant, I strongly suggest you to read a good tutorial about the theory of the algorithm.

more