Adaptive thresholding now working :-)