Stroke Width Transform: Gradient Direction Computation 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.

on the segment of computing the gradient direction, given the equation:

theta = arctan( Gy / Gx )

where: 


theta = is the resulting angle
Gx = is the X gradient component
Gy = is the Y gradient component
(both Gx and Gy are from the gradient maps)


I got a bit confused. If the value of Gx is 0 (zero), and we all know dividing by zero is undefined (some say it's infinity), so are we going to make theta infinity or just 0 (zero)?
If $Gx = 0$ and $Gy &gt; 0$, then we use $Gy / 0 = + \infty$. Note that $\arctan +\infty = 1$.

If $Gx = 0$ and $Gy &lt; 0$, then we use $Gy / 0 = -\infty$.  Note that $\arctan -\infty = -1$.