My algorithm is
rgb -> gray -> blur -> binarization (for correct the nonuniform of background) -> dilate -> otsu -> morphologyEX
gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
blurred = cv2.GaussianBlur(gray, (3, 3), 0)
se = cv2.getStructuringElement(cv2.MORPH_RECT, (10, 10))
bg = cv2.morphologyEx(blurred, cv2.MORPH_DILATE, se)
out_gray = cv2.divide(blurred, bg, scale=255)
out_binary = cv2.threshold(out_gray, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1]
# kernel = np.ones((2, 2), np.uint8)
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (1, 3))
result = cv2.morphologyEx(out_binary, cv2.MORPH_CLOSE, kernel)
I want to output [3 0 3 8 6 7 0 8 1]