src/search_engine/relja_retrival/external/KMCode_relja/descriptor/ESiftDescriptor.cpp
void ESiftDescriptor::PlaceInIndex(float *index, 
		  float mag, float ori, float rx, float cx, int eindexSize)
{
   int r, c, ort, ri, ci, oi, rindex, cindex, oindex, rcindex;
   float oval, rfrac, cfrac, ofrac, rweight, cweight, oweight;
   
   oval = EOriSize * ori / (M_2PI);//CHANGED from M_2PI 
   
   ri = (int)((rx >= 0.0) ? rx : rx - 1.0);  /* Round down to next integer. */
   ci = (int)((cx >= 0.0) ? cx : cx - 1.0);
   oi = (int)((oval >= 0.0) ? oval : oval - 1.0);
   rfrac = rx - ri;         /* Fractional part of location. */
   cfrac = cx - ci;
   ofrac = oval - oi;
   /*   assert(ri >= -1  &&  ri < IndexSize  &&  oi >= 0  &&  oi <= OriSize  && rfrac >= 0.0  &&  rfrac <= 1.0);*/
   //if(oval<0 || oval>4 || ofrac>1.0 )cout << "error : "<< oval<<" "<< ofrac <<endl;
   /* 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. */
   for (r = 0; r < 2; r++) {
      rindex = ri + r;
      if (rindex >=0 && rindex < eindexSize) {
         rweight = mag * ((r == 0) ? 1.0 - rfrac : rfrac);
         
         for (c = 0; c < 2; c++) {
            cindex = ci + c;
            if (cindex >=0 && cindex < eindexSize) {
               cweight = rweight * ((c == 0) ? 1.0 - cfrac : cfrac);
               rcindex=(rindex*eindexSize+cindex)<<3;//ATTANTION SHOULD BE 3 for 8 orientations
               for (ort = 0; ort < 2; ort++) {
                  oindex = oi + ort;
                  if (oindex >= EOriSize)  /* Orientation wraps around at PI. */
                     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.  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 ESiftDescriptor::PlaceInIndex(float *index, 
		  float mag, float ori, float rx, float cx, int eindexSize)
{
   int r, c, ort, ri, ci, oi, rindex, cindex, oindex, rcindex;
   float oval, rfrac, cfrac, ofrac, rweight, cweight, oweight;
   oval = EOriSize * 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 < eindexSize) {
         rweight = mag * ((r == 0) ? 1.0 - rfrac : rfrac);
         for (c = 0; c < 2; c++) {
            cindex = ci + c;
            if (cindex >=0 && cindex < eindexSize) {
               cweight = rweight * ((c == 0) ? 1.0 - cfrac : cfrac);
               rcindex=(rindex*eindexSize+cindex)<<3;
               for (ort = 0; ort < 2; ort++) {
                  oindex = oi + ort;
                  if (oindex >= EOriSize)  
                     oindex = 0;
                  oweight = cweight * ((ort == 0) ? 1.0 - ofrac : ofrac);
		  index[rcindex+oindex]+=oweight;
               }
            }  
         }
      }
   } 
}
void ESiftDescriptor :: PlaceInIndex ( float * index , float mag , float ori , float rx , float cx , int eindexSize ) { int r , c , ort , ri , ci , oi , rindex , cindex , oindex , rcindex ; float oval , rfrac , cfrac , ofrac , rweight , cweight , oweight ; oval = EOriSize * 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 < eindexSize ) { rweight = mag * ( ( r == 0 ) ? 1.0 - rfrac : rfrac ) ; for ( c = 0 ; c < 2 ; c ++ ) { cindex = ci + c ; if ( cindex >= 0 && cindex < eindexSize ) { cweight = rweight * ( ( c == 0 ) ? 1.0 - cfrac : cfrac ) ; rcindex = ( rindex * eindexSize + cindex ) << 3 ; for ( ort = 0 ; ort < 2 ; ort ++ ) { oindex = oi + ort ; if ( oindex >= EOriSize ) 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 .
//CHANGED from M_2PI  /* Round down to next integer. */ /* Fractional part of location. */ /*   assert(ri >= -1  &&  ri < IndexSize  &&  oi >= 0  &&  oi <= OriSize  && rfrac >= 0.0  &&  rfrac <= 1.0);*/ //if(oval<0 || oval>4 || ofrac>1.0 )cout << "error : "<< oval<<" "<< ofrac <<endl; /* 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. */ //ATTANTION SHOULD BE 3 for 8 orientations /* Orientation wraps around at PI. */