I want to find the direction of stroke in text.How to used Sobel operator for this purpose?
This image show dp .which is gradient direction.I wanted to know how I can apply Sobel operator for finding pixel to chose (from p to q)along path to find other end q of pixel in edge.
The Sobel operator performs a 2-D spatial gradient measurement on an image and so emphasizes regions of high spatial frequency that correspond to edges. Typically it is used to find the approximate absolute gradient magnitude at each point in an input grayscale image.
The Roberts Cross operator performs a simple, quick to compute, 2-D spatial gradient measurement on an image. It thus highlights regions of high spatial frequency which often correspond to edges. In its most common usage, the input to the operator is a grayscale image, as is the output.
In digital images, a gradient operator is similar to an averaging operator (for noise removal), which is a weighted convolution operator utilizing the neighboring pixels for the operation. However, unlike the averaging operator, the weightings of a gradient operator are not exclusively positive integers.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With