title: What does the gradient from Sobel mean?
body: <p>I have the gradients from the Sobel operator for each pixel. In my case 320x480. But how can I relate them with the orientation? For an example, I'm planning to draw an orientation map for fingerprints. So, how do I start? </p>
  
  <p>Is it by dividing the gradients into blocks (example 16x24) then adding the gradients together and diving it by 384 to get the average gradients? Then from there draw a line from the center of the block using the average gradient?</p>
  
  <p>Correct me if i'm wrong. Thank you.</p>
  
  <p>Here are the codes that i used to find gradients</p>
  
  <pre><code>cv::Mat original_Mat=cv::imread("original.bmp", 1);
  
  cv::Mat grad = cv::Mat::zeros(original_Mat.size(), CV_64F);
  
  cv::Mat grad_x = cv::Mat::zeros(original_Mat.size(), CV_64F); 
  cv::Mat grad_y = cv::Mat::zeros(original_Mat.size(), CV_64F);
  
  /// Gradient X
  cv::Sobel(original_Mat, grad_x, CV_16S, 1, 0, 3);
  
  /// Gradient Y
  cv::Sobel(original_Mat, grad_y, CV_16S, 0, 1, 3);
  
  short* pixelX = grad_x.ptr&lt;short&gt;(0);
  short* pixelY = grad_y.ptr&lt;short&gt;(0);
  
  int count = 0;
  int min = 999999;
  int max = -1;
  int a=0,b=0;
  
  for(int i = 0; i &lt; grad_x.rows * grad_x.cols; i++) 
  {
      double directionRAD = atan2(pixelY[i], pixelX[i]);
      int directionDEG = (int)(180 + directionRAD / CV_PI * 180);
  
      //printf("%d ",directionDEG);
      if(directionDEG &lt; min){min = directionDEG;}
      if(directionDEG &gt; max){max = directionDEG;}
  
  
      if(directionDEG &lt; 0 || directionDEG &gt; 360)
      {
          cout&lt;&lt;"Weird gradient direction given in method: getGradients.";
      }
  
  }
  </code></pre>