title: The direction of Gradient Filter in openCV
body: <p>thanks for taking a look.</p>
  
  <p>The question pops up when I read concepts help on <a href="http://zone.ni.com/reference/en-XX/help/372916L-01/nivisionconcepts/spatial_filtering/" rel="nofollow noreferrer">this website</a></p>
  
  <p>When applying a gradient convolution filter, with a different given direction, different edges are given depending on light intensity, see following:</p>
  
  <p><a href="https://i.stack.imgur.com/hyRkz.png" rel="nofollow noreferrer">filter result with positive direction</a></p>
  
  <p><a href="https://i.stack.imgur.com/ZNx5F.png" rel="nofollow noreferrer">filter result with negative direction</a></p>
  
  <p>Then I tried to implement the same in opencv with <code>cv2.Sobel</code> in y axis. </p>
  
  <pre><code>cv2.Sobel(img,cv2.CV_8U,0,1)  
  </code></pre>
  
  <p>The code only shows detected edges in one direction. I didn't manage to change the direction to show the edge detected with another intensity.</p>
  
  <p>I am aware that with <code>CV_64</code>, one can detect both, but I wish to have them separately, exactly same as the example showed previously.</p>
  
  <p>I found a trick to invert b/w of the image <code>img=255-img</code>, afterwards applying the same filter <code>cv2.Sobel(img,cv2.CV_8U,0,1)</code> cloud show the other edge as I expected.</p>
  
  <p>I was wondering if it is possible just by <code>cv2.Sobel</code> function or any other opencv filter to control this filter direction without the need of inverting b/w of image .</p>