1

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.

Community
  • 1
  • 1
madan ram
  • 1,260
  • 2
  • 19
  • 26
  • Another project in Python of the SWT implementation can be found here : https://github.com/ag-ds-bubble/swtloc – Dravidian Sep 23 '20 at 10:32

1 Answers1

2

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;
Haris
  • 13,645
  • 12
  • 90
  • 121
  • I tested this as code which work well.But I am not able to understand how equation at first work.It would be helpful if you can explain some math about.thank for solution... – madan ram Mar 16 '14 at 18:05
  • Acually it is parametric equation of circle you can find nore info [here](http://www.mathopenref.com/coordparamcircle.html) – Haris Mar 17 '14 at 09:47