0

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)

Input image Algorithm output

I want to output [3 0 3 8 6 7 0 8 1]

vamiskun
  • 11
  • 3
  • You can easily detect `30386` applying `adaptive-threshold` and `erosion`. However 7081 is challenging. – Ahmet Feb 10 '21 at 20:54
  • Tesseract usually prefers black text on white background. For a picture like this, you might try perspective correction. [This answer](https://stackoverflow.com/q/66219912/9705687) has a nice example. Finally, you'll have to play with [thresholding](https://docs.opencv.org/master/d7/d4d/tutorial_py_thresholding.html) and [morphology](https://docs.opencv.org/master/d9/d61/tutorial_py_morphological_ops.html) operations to get the picture cleaned up. – bfris Feb 19 '21 at 18:21

0 Answers0