load file and adaptive thresholding