Adaptive thresholding implemented.