implented binarisation algorithm.