niblack: add code to perform Niblack's segmentation