Fix adaptive thresholding.