Just some comments
Added a second condition to nonMaximumSuppress function to avoid 2-pixel width edges that lie on the same direction