madan ram
madan ram

Reputation: 1270

Sobel operator for gradient angle

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.

Upvotes: 5

Views: 10627

Answers (1)

Andrey  Smorodov
Andrey Smorodov

Reputation: 10852

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);

Upvotes: 11

Related Questions