worked on edgecon, gradient

gradient is supposed to calculate two fields for an image, the magnitude
and direction of the gradient. currently am testing it with an image of
a circle. having issues with the direction results(atan function goes
from -90* to 90*, not 180...

would like to use the direction to help determine how edgecon works,
hopefully that would stop nearby parallel lines from connecting, and
would allow me to not use the segment rule so that on the last step the
continuous C shape can close.

paper:
http://www.ece.iastate.edu/~namrata/EE528_Spring07/EdgeDetection_BoundaryTracing.pdf
http://link.springer.com/chapter/10.1007%2F978-0-85729-997-0_5