5

I want to find the direction of the stroke in text. How can the Sobel operator be used for this purpose?

enter image description here

This image shows dp, which is the gradient direction. I wanted to know how I can apply the Sobel operator to find which pixel to choose, from p to q, along the path sp, to find the end pixel q on the edge.

mgmussi
  • 520
  • 1
  • 4
  • 19
madan ram
  • 1,260
  • 2
  • 19
  • 26

1 Answers1

11

You can find x derivative of image, then y derivative.

Sobel(Img,gxx,CV_32FC1,1,0); //  x derivative
Sobel(Img,gyy,CV_32FC1,0,1); //  y derivative

After that find phase http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#phase

phase(gxx,gyy,angles,inDegrees);
Daniel
  • 10,864
  • 22
  • 84
  • 115
Andrey Smorodov
  • 10,649
  • 2
  • 35
  • 42