Adaptive thresholding in OpenCV