Derivative thresholding