I want to find the direction of impact in the text. How to use the Sobel operator for this purpose?

This image shows dp., Which is the direction of the gradient. I wanted to know how I can apply the Sobel operator to search for a pixel to select (p to q) along the path to find the other end of the q pixel in the edge.
source
share