Skip to content Skip to sidebar Skip to footer

Various Thresholding Methods Implementation In Python Opecv2

I want to compare the performance of various thresholding methods. Literally, I found various thresholding methods are Histogram shape based methods (Ex:- Otsu Method) Clustering

Solution 1:

Example for Otsu:

high_thresh, thresh_im = cv2.threshold(im, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
lowThresh = 0.5*high_thresh

You can find other possible flags for the Threshold Function in the documentation. This includes: BINARY, BINARY_INV, TRUNC, TOZERO and TOZERO_INV.

More adaptive Threshold are listed here. Adaptive modes are: ADAPTIVE_THRESH_MEAN_C and ADAPTIVE_THRESH_GAUSSIAN_C.

Otherwise it is usually pretty simple to implement other Threshold Methods using OpenCV.

Post a Comment for "Various Thresholding Methods Implementation In Python Opecv2"