Otsu automatically determines the optimal threshold using histogram variance minimization.
import cv2 def otsu_threshold(img): gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) _, t = cv2.threshold(gray,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU) return t← Back to Gallery