Reputation: 1270
I have an image I wanted to find stroke width in the image. So far i am able to find phase angle from Sobel operator.Now how to use it find width.
Sobel operator for gradient angle
give post related to finding angle but not the stroke width please help.
Upvotes: 1
Views: 1870
Reputation: 14053
Assume you have initial point and angle(gradient).
Then using equation
x2 = x1 + length * cos(θ)
y2 = y1 + length * sin(θ)
and θ should be in radians
θ= angle * 3.14 / 180.0
In a loop find x2,y2 by increasing length gradually, and for each x2,y2 access pixel value and check whether it is your stroke color, if it is increment a counter else break the loop and take the value of counter as your stroke width.
Vec3b pix=image.at<Vec3b>(y2,x2);
if(pix==yourstrokColor)
strokeWidth++;
else break;
Upvotes: 2