img_gray = cv2.imread(r"./example.png", 0)
# the threshold you want is thr
thr = 127
bw = ((img_gray / (thr * 2)) > 0.5).astype(np.uint8) * 255 # INV: ">" -> "<"
转载于:https://www.cnblogs.com/ZhengPeng7/p/7859870.html
img_gray = cv2.imread(r"./example.png", 0)
# the threshold you want is thr
thr = 127
bw = ((img_gray / (thr * 2)) > 0.5).astype(np.uint8) * 255 # INV: ">" -> "<"
转载于:https://www.cnblogs.com/ZhengPeng7/p/7859870.html