Fixed thresholding bug for fitEdge function