src/search_engine/relja_retrival/external/KMCode_relja/descriptor/dog.cpp
/* Assign an orientation to this keypoint.  This is done by
     creating a Gaussian weighted histogram of the gradient directions in
     the region.  The histogram is smoothed and the largest peak selected.
     The results are in the range of -PI to PI.
*/
Assign an orientation to this keypoint.  This is done by
creating a Gaussian weighted histogram of the gradient directions in
the region.  The histogram is smoothed and the largest peak selected.
The results are in the range of -PI to PI.
Assign an orientation to this keypoint . This is done by creating a Gaussian weighted histogram of the gradient directions in the region . The histogram is smoothed and the largest peak selected . The results are in the range of - PI to PI .
float FindOri(DARY * grad, DARY * ori, int row, int col)
{
    int i, r, c, rows, cols, radius, bin;
    const int OriBins=36;
    float hist[OriBins], distsq, gval, weight, angle;
    float OriSigma=3.0;
    rows = grad->y();
    cols = grad->x();
    for (i = 0; i < OriBins; i++)
      hist[i] = 0.0;
    radius = (int) (OriSigma * 3.0);
    for (r = row - radius; r <= row + radius; r++)
      for (c = col - radius; c <= col + radius; c++)
	if (r >= 0 && c >= 0 && r < rows - 2 && c < cols - 2) {
	  gval = grad->fel[r][c];
	  distsq = (r - row) * (r - row) + (c - col) * (c - col);
	  if (gval > 0.0  &&  distsq < radius * radius + 0.5) {
	    weight = exp(- distsq / (2.0 * OriSigma * OriSigma));
	    angle = ori->fel[r][c];
	    bin = (int) (OriBins * (angle + M_PI + 0.001) / (2.0 * M_PI));
	    assert(bin >= 0 && bin <= OriBins);
	    if(bin>(OriBins - 1))bin=(OriBins - 1);
	    hist[bin] += weight * gval;
	  }
	}
    SmoothHistogram(hist, OriBins);
    SmoothHistogram(hist, OriBins);
    return FindOriPeaks(hist, OriBins);
}
float FindOri ( DARY * grad , DARY * ori , int row , int col ) { int i , r , c , rows , cols , radius , bin ; const int OriBins = 36 ; float hist [ OriBins ] , distsq , gval , weight , angle ; float OriSigma = 3.0 ; rows = grad -> y ( ) ; cols = grad -> x ( ) ; for ( i = 0 ; i < OriBins ; i ++ ) hist [ i ] = 0.0 ; radius = ( int ) ( OriSigma * 3.0 ) ; for ( r = row - radius ; r <= row + radius ; r ++ ) for ( c = col - radius ; c <= col + radius ; c ++ ) if ( r >= 0 && c >= 0 && r < rows - 2 && c < cols - 2 ) { gval = grad -> fel [ r ] [ c ] ; distsq = ( r - row ) * ( r - row ) + ( c - col ) * ( c - col ) ; if ( gval > 0.0 && distsq < radius * radius + 0.5 ) { weight = exp ( - distsq / ( 2.0 * OriSigma * OriSigma ) ) ; angle = ori -> fel [ r ] [ c ] ; bin = ( int ) ( OriBins * ( angle + M_PI + 0.001 ) / ( 2.0 * M_PI ) ) ; assert ( bin >= 0 && bin <= OriBins ) ; if ( bin > ( OriBins - 1 ) ) bin = ( OriBins - 1 ) ; hist [ bin ] += weight * gval ; } } SmoothHistogram ( hist , OriBins ) ; SmoothHistogram ( hist , OriBins ) ; return FindOriPeaks ( hist , OriBins ) ; }
Assign an orientation to this keypoint.
Assign an orientation to this keypoint .
/* Look at pixels within 3 sigma around the point and put their
       Gaussian weighted values in the histogram. */ /* Do not use last row or column, which are not valid. */ /* Ori is in range of -PI to PI. */ /* Apply smoothing twice. */