3
$\begingroup$

I've been trying to implement this paper from Boris Epshtein, Eyal Ofek, and Yonatan Wexler, the pioneers of Stroke Width Transform .

Having a simple image with random texts, that underwent gray scaling. Then I have produced two edge maps using two different algorithms for output comparison (for later) , Sobel and Canny (I'm also planning on Prewwit or other edge detection algorithms). I also have gradient maps x and y, using sobel.

Now, up to this point I got lost on the second paragraph of section 3.1 of the paper, which is getting a gradient direction and finding the other point for the ray: " ...then dp must be roughly perpendicular to the orientation of the stroke... " and " ... dp(dq = -dp±π/6) ... ". Does this mean I'll have to take a wild guess as to where the direction of dq is? or have I misinterpreted it?

$\endgroup$
2
$\begingroup$

You basically have to sample points from p in the direction of p's gradient dp.
You get the dp from the x and y gradient maps. And sample from where? from the edge map and the gradient maps. First check if it is a edge from the edge map. If it is not then take another step in the dp direction. If it is an edge then compute the gradient direction from the x and y gradient map. If that gradient points back to p with about π/6 of tolerance then that is the q you are looking for.

Be careful with back over while vs white over black. The gradients will point in opposites directions when you invert the image. That is why you have to run the algorithm twice since SWT does not know which case are we dealing with. One with the original gradient directions and another flipping the gradients in the opposite direction.

$\endgroup$
  • $\begingroup$ I see, I thought the actual direction from p to q was π/6. So it was actually just π/6 of tolerance. Thank you. $\endgroup$ – MrCzeal Mar 7 '17 at 9:54
  • $\begingroup$ feel free to play with the tolerance value. In practice I have found that a large value might find more points. It depends on the actual image and the edge detector params. $\endgroup$ – AZoo Mar 7 '17 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.