As we saw in previous sections, the simple thresholding algorithm applies an arbitrary global threshold value. In this case, what we need to do is experiment with different thresholding values and look at the thresholded images in order to see if the result satisfies our necessities. However, this approach can be very tedious.
One solution is to use the adaptive thresholding that OpenCV provides by means of the cv2.adapativeThreshold() function. When applying adaptive thresholding in OpenCV, there is no need to set a thresholding value, which is a good thing.
However, two parameters should be established correctly: the blockSize parameter and the C parameter. Another approach is to use Otsu's binarization algorithm, which is a good approach when dealing with bimodal images. A bimodal image can be characterized by its histogram containing...