The cv2.threshold() function can also be applied to multi-channel images. This can be seen in the thresholding_bgr.py script. In this case, the cv2.threshold() function applies the thresholding operation in each of the channels of the BGR image. This produces the same result as applying this function in each channel and merging the thresholded channels:
ret1, thresh1 = cv2.threshold(image, 150, 255, cv2.THRESH_BINARY)
Therefore, the preceding line of code produces the same result as performing the following:
(b, g, r) = cv2.split(image)
ret2, thresh2 = cv2.threshold(b, 150, 255, cv2.THRESH_BINARY)
ret3, thresh3 = cv2.threshold(g, 150, 255, cv2.THRESH_BINARY)
ret4, thresh4 = cv2.threshold(r, 150, 255, cv2.THRESH_BINARY)
bgr_thresh = cv2.merge((thresh2, thresh3, thresh4))
The result can be seen in the following screenshot:
Although you can perform cv2.threshold...