The preprocessing step uses otsu, which is pretty inaccurate, because it uses only one single threshold value for the whole image. An adaptive thresholding algorithm (like Sauvola or Wolf binarization) could improve the whole preprocessing A LOT on many images, that are not only black and white. See https://github.com/chriswolfvision/local_adaptive_binarizati... for details.