Refactored and cleaned up code for line segment detection via connected edgel components