Added adaptive thresholding
fix adaptive threshold