3rdparty/OpenCV-2.3.0/modules/features2d/src/sift.cpp
static int calc_grad_mag_ori( IplImage* img, int r, int c, double* mag,
                              double* ori )
{
  double dx, dy;

  if( r > 0  &&  r < img->height - 1  &&  c > 0  &&  c < img->width - 1 )
    {
      dx = pixval32f( img, r, c+1 ) - pixval32f( img, r, c-1 );
      dy = pixval32f( img, r-1, c ) - pixval32f( img, r+1, c );
      *mag = sqrt( dx*dx + dy*dy );
      *ori = atan2( dy, dx );
      return 1;
    }

  else
    return 0;
}
/*
  Calculates the gradient magnitude and orientation at a given pixel.

  @param img image
  @param r pixel row
  @param c pixel col
  @param mag output as gradient magnitude at pixel (r,c)
  @param ori output as gradient orientation at pixel (r,c)

  @return Returns 1 if the specified pixel is a valid one and sets mag and
    ori accordingly; otherwise returns 0
*/
Calculates the gradient magnitude and orientation at a given pixel.
Calculates the gradient magnitude and orientation at a given pixel .
static int calc_grad_mag_ori( IplImage* img, int r, int c, double* mag,
                              double* ori )
{
  double dx, dy;
  if( r > 0  &&  r < img->height - 1  &&  c > 0  &&  c < img->width - 1 )
    {
      dx = pixval32f( img, r, c+1 ) - pixval32f( img, r, c-1 );
      dy = pixval32f( img, r-1, c ) - pixval32f( img, r+1, c );
      *mag = sqrt( dx*dx + dy*dy );
      *ori = atan2( dy, dx );
      return 1;
    }
  else
    return 0;
}
static int calc_grad_mag_ori ( IplImage * img , int r , int c , double * mag , double * ori ) { double dx , dy ; if ( r > 0 && r < img -> height - 1 && c > 0 && c < img -> width - 1 ) { dx = pixval32f ( img , r , c + 1 ) - pixval32f ( img , r , c - 1 ) ; dy = pixval32f ( img , r - 1 , c ) - pixval32f ( img , r + 1 , c ) ; * mag = sqrt ( dx * dx + dy * dy ) ; * ori = atan2 ( dy , dx ) ; return 1 ; } else return 0 ; }
Calculates the gradient magnitude and orientation at a given pixel.
Calculates the gradient magnitude and orientation at a given pixel .