src/search_engine/relja_retrival/external/KMCode_relja/descriptor/SiftDescriptor.cpp
/* Add features to vec obtained from sampling the grad and ori images
   for a particular scale.  Location of key is (scale,row,col) with respect
   to images at this scale.  We examine each pixel within a circular
   region containing the keypoint, and distribute the gradient for that
   pixel into the appropriate bins of the index array.
*/
Add features to vec obtained from sampling the grad and ori images
for a particular scale.  Location of key is (scale,row,col) with respect
to images at this scale.  We examine each pixel within a circular
region containing the keypoint, and distribute the gradient for that
pixel into the appropriate bins of the index array.
Add features to vec obtained from sampling the grad and ori images for a particular scale . Location of key is ( scale row col ) with respect to images at this scale . We examine each pixel within a circular region containing the keypoint and distribute the gradient for that pixel into the appropriate bins of the index array .
void SiftDescriptor::KeySample(float *index, DARY *grad, DARY *ori)
{
   int i, j, iradius, irow, icol;
   float spacing, sine, cosine, rpos, cpos, rx, cx;
   iradius = grad->x()>>1;
   spacing = (IndexSize + 1) / (2.0*iradius);
   for (i = -iradius; i <= iradius; i++)
     for (j = -iradius; j <= iradius; j++) {
       rpos = i * spacing;
       cpos = j * spacing;
       rx = rpos + (IndexSize - 1) / 2.0;
       cx = cpos + (IndexSize - 1) / 2.0;
       if (rx > -1.0 && rx < (float) IndexSize  &&
	   cx > -1.0 && cx < (float) IndexSize)
	 AddSample(index, grad, ori, iradius + i, iradius + j, rpos, cpos,
		   rx, cx);
   } 
}
void SiftDescriptor :: KeySample ( float * index , DARY * grad , DARY * ori ) { int i , j , iradius , irow , icol ; float spacing , sine , cosine , rpos , cpos , rx , cx ; iradius = grad -> x ( ) >> 1 ; spacing = ( IndexSize + 1 ) / ( 2.0 * iradius ) ; for ( i = - iradius ; i <= iradius ; i ++ ) for ( j = - iradius ; j <= iradius ; j ++ ) { rpos = i * spacing ; cpos = j * spacing ; rx = rpos + ( IndexSize - 1 ) / 2.0 ; cx = cpos + ( IndexSize - 1 ) / 2.0 ; if ( rx > -1.0 && rx < ( float ) IndexSize && cx > - 1.0 && cx < ( float ) IndexSize ) AddSample ( index , grad , ori , iradius + i , iradius + j , rpos , cpos , rx , cx ) ; } }
Add features to vec obtained from sampling the grad and ori images
for a particular scale.
Add features to vec obtained from sampling the grad and ori images for a particular scale .
/* Radius of index sample region must extend to diagonal corner of
      index patch plus half sample for interpolation. */ //   printf("spacing %f, scale %f, radius %d\n",spacing,scale, iradius); // Examine all points from the gradient image that could lie within the index square.  // Compute location of sample in terms of real-valued index array //  coordinates.  Subtract 0.5 so that rx of 1.0 means to put full // weight on index[1] (e.g., when rpos is 0 and IndexSize is 3.  //cout <<"rx " << rx << " " << cx << endl; // Test whether this sample falls within boundary of index patch.  //cout << "in" << cpos << " " << rpos << endl;