1

Hello,

I have 2D matrix with greyscale image data, in particular point I have computed vector, which contains gradient in this point (via Sobel operator, it has 2 values - difference in x and in y axis), and I store this gradient vector like perpendicular vector to this gradient, so I have the vector, which says me the orientation of the edge in this point.

Now, what I want - I want to draw orientation of this edge in that particular point in my 2D image matrix like small line (for example 10 pixels) and I want to draw it in the way of this vector I have computed.

Any idea, how to do that?

Thanks for any help!

Well I am not exactly sure what you are trying to do, but i have worked with the sobel operator before in an edge detector. Assuming you know how to apply the x and y sobel operators to get the x and y gradient values (here they are Gx and Gy) then you can calculate the direction (theta) and magnitude of the gradient at every point. Here is a code snippet:

  /* Two theta condtions, need manual setting */
  if(Gx == 0){
    if(Gy == 0) //if Gx and Gy are zero, theta is zero
      theta = 0;
    else 
      theta = 90; // Gx is zero and Gy is non-zero, theta is 90
  }
  /* if not condition, calculate actual edge direction */ ...