src/search_engine/relja_retrival/external/KMCode_relja/descriptor/SiftDescriptor.cpp
/* Increment the appropriate locations in the index to incorporate
   this image sample.  The location of the sample in the index is (rx,cx). 
*/
Increment the appropriate locations in the index to incorporate
this image sample.  The location of the sample in the index is (rx,cx).
Increment the appropriate locations in the index to incorporate this image sample . The location of the sample in the index is ( rx cx ) .
void SiftDescriptor::PlaceInIndex(float *index,
		  float mag, float ori, float rx, float cx)
{
   int r, c, ort, ri, ci, oi, rindex, cindex, oindex, rcindex;
   float oval, rfrac, cfrac, ofrac, rweight, cweight, oweight;
   oval = OriSize * ori / (M_2PI);
   ri = (int)((rx >= 0.0) ? rx : rx - 1.0);  
   ci = (int)((cx >= 0.0) ? cx : cx - 1.0);
   oi = (int)((oval >= 0.0) ? oval : oval - 1.0);
   rfrac = rx - ri;         
   cfrac = cx - ci;
   ofrac = oval - oi; 
   for (r = 0; r < 2; r++) {
      rindex = ri + r;
      if (rindex >=0 && rindex < IndexSize) {
         rweight = mag * ((r == 0) ? 1.0 - rfrac : rfrac);
         for (c = 0; c < 2; c++) {
            cindex = ci + c;
            if (cindex >=0 && cindex < IndexSize) {
               cweight = rweight * ((c == 0) ? 1.0 - cfrac : cfrac);
               rcindex=(rindex*IndexSize+cindex)<<3;
               for (ort = 0; ort < 2; ort++) {
                  oindex = oi + ort;
                  if (oindex >= OriSize)  
                     oindex = 0;
                  oweight = cweight * ((ort == 0) ? 1.0 - ofrac : ofrac);
		  index[rcindex+oindex]+=oweight;
               }
            }  
         }
      }
   } 
}
void SiftDescriptor :: PlaceInIndex ( float * index , float mag , float ori , float rx , float cx ) { int r , c , ort , ri , ci , oi , rindex , cindex , oindex , rcindex ; float oval , rfrac , cfrac , ofrac , rweight , cweight , oweight ; oval = OriSize * ori / ( M_2PI ) ; ri = ( int ) ( ( rx >= 0.0 ) ? rx : rx - 1.0 ) ; ci = ( int ) ( ( cx >= 0.0 ) ? cx : cx - 1.0 ) ; oi = ( int ) ( ( oval >= 0.0 ) ? oval : oval - 1.0 ) ; rfrac = rx - ri ; cfrac = cx - ci ; ofrac = oval - oi ; for ( r = 0 ; r < 2 ; r ++ ) { rindex = ri + r ; if ( rindex >= 0 && rindex < IndexSize ) { rweight = mag * ( ( r == 0 ) ? 1.0 - rfrac : rfrac ) ; for ( c = 0 ; c < 2 ; c ++ ) { cindex = ci + c ; if ( cindex >= 0 && cindex < IndexSize ) { cweight = rweight * ( ( c == 0 ) ? 1.0 - cfrac : cfrac ) ; rcindex = ( rindex * IndexSize + cindex ) << 3 ; for ( ort = 0 ; ort < 2 ; ort ++ ) { oindex = oi + ort ; if ( oindex >= OriSize ) oindex = 0 ; oweight = cweight * ( ( ort == 0 ) ? 1.0 - ofrac : ofrac ) ; index [ rcindex + oindex ] += oweight ; } } } } } }
Increment the appropriate locations in the index to incorporate
this image sample.
Increment the appropriate locations in the index to incorporate this image sample .
/* Round down to next integer. */ /* Fractional part of location. */ /*   assert(ri >= -1  &&  ri < IndexSize  &&  oi >= 0  &&  oi <= OriSize  && rfrac >= 0.0  &&  rfrac <= 1.0);*/ /* Put appropriate fraction in each of 8 buckets around this point
      in the (row,col,ori) dimensions.  This loop is written for
      efficiency, as it is the inner loop of key sampling. */ /* Orientation wraps around at PI. */