我想在文本中找到笔画的方向.如何使用Sobel算子?

这个图像显示了dp.它是渐变方向.我想知道如何应用Sobel算子来找到沿路径选择(从p到q)的像素,找到边缘像素的另一端q.
你可以找到图像的x导数,然后是y导数.
Sobel(Img,gxx,CV_32FC1,1,0); // x derivative
Sobel(Img,gyy,CV_32FC1,0,1); // y derivative
Run Code Online (Sandbox Code Playgroud)
之后找到阶段 http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#phase
phase(gxx,gyy,angles,inDegrees);
Run Code Online (Sandbox Code Playgroud)