import cv2
import os
#OTUS阈值分割法
def OTUS(img_path,save_path):
imgs_path = os.listdir(img_path)
for r in imgs_path:
img=os.path.join(img_path,r)
img = cv2.imread(img)
gray=cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) #BGR图(cv2读取的是BGR,不是RGB)转为灰度图
_,th = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)
cv2.imwrite(save_path+r, th)
01-28
8932

09-27
8888

05-08
4899

05-08
1896

05-13
2839
