proto thresholding algorithm