Added a hysteresis function (needs improvement!)
and more helper functions: traverseEdge and getNeighborEdges
Refactored to use setPixel function
Fixed the bug in the traverseEdge function to pass threshold with recursive call