test for optimal binarization