Python grayscale image to binary image
img = cv2.imread("G:/imgHui/jiaoshi.jpg")
Grayimg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(Grayimg, 120, 225,cv2.THRESH_BINARY)
cv2.imwrite('G:/imgHui/2.jpg', thresh)
The
first parameter of the threshold is the grayscale image and the
second parameter is the threshold