3rdparty/OpenCV-2.3.0/modules/features2d/src/sift.cpp
static double* ori_hist( IplImage* img, int r, int c, int n, int rad,
                         double sigma )
{
  double* hist;
  double mag, ori, w, exp_denom, PI2 = CV_PI * 2.0;
  int bin, i, j;

  hist = (double*) calloc( n, sizeof( double ) );
  exp_denom = 2.0 * sigma * sigma;
  for( i = -rad; i <= rad; i++ )
    for( j = -rad; j <= rad; j++ )
      if( calc_grad_mag_ori( img, r + i, c + j, &mag, &ori ) )
        {
          w = exp( -( i*i + j*j ) / exp_denom );
          bin = cvRound( n * ( ori + CV_PI ) / PI2 );
          bin = ( bin < n )? bin : 0;
          hist[bin] += w * mag;
        }

  return hist;
}
/*
  Computes a gradient orientation histogram at a specified pixel.

  @param img image
  @param r pixel row
  @param c pixel col
  @param n number of histogram bins
  @param rad radius of region over which histogram is computed
  @param sigma std for Gaussian weighting of histogram entries

  @return Returns an n-element array containing an orientation histogram
    representing orientations between 0 and 2 PI.
*/
Computes a gradient orientation histogram at a specified pixel.
Computes a gradient orientation histogram at a specified pixel .
static double* ori_hist( IplImage* img, int r, int c, int n, int rad,
                         double sigma )
{
  double* hist;
  double mag, ori, w, exp_denom, PI2 = CV_PI * 2.0;
  int bin, i, j;
  hist = (double*) calloc( n, sizeof( double ) );
  exp_denom = 2.0 * sigma * sigma;
  for( i = -rad; i <= rad; i++ )
    for( j = -rad; j <= rad; j++ )
      if( calc_grad_mag_ori( img, r + i, c + j, &mag, &ori ) )
        {
          w = exp( -( i*i + j*j ) / exp_denom );
          bin = cvRound( n * ( ori + CV_PI ) / PI2 );
          bin = ( bin < n )? bin : 0;
          hist[bin] += w * mag;
        }
  return hist;
}
static double * ori_hist ( IplImage * img , int r , int c , int n , int rad , double sigma ) { double * hist ; double mag , ori , w , exp_denom , PI2 = CV_PI * 2.0 ; int bin , i , j ; hist = ( double * ) calloc ( n , sizeof ( double ) ) ; exp_denom = 2.0 * sigma * sigma ; for ( i = - rad ; i <= rad ; i ++ ) for ( j = - rad ; j <= rad ; j ++ ) if ( calc_grad_mag_ori ( img , r + i , c + j , & mag , & ori ) ) { w = exp ( - ( i * i + j * j ) / exp_denom ) ; bin = cvRound ( n * ( ori + CV_PI ) / PI2 ) ; bin = ( bin < n ) ? bin : 0 ; hist [ bin ] += w * mag ; } return hist ; }
Computes a gradient orientation histogram at a specified pixel.
Computes a gradient orientation histogram at a specified pixel .