Trying to pre-process an image and read it using tesseract and pillow. The image looks good to me, but it still keeps misreading some numbers. It keeps reading the value after Stamina as 7 instead of 17, same with Natural Fitness and Teamwork. The 1 looks very clear to me and I don't understand why it struggles to read the 1 in 17 specifically. What would be some steps in pre-processing i could take to make it more accurate?
image = Image.open(image_path)
grayscale = image.convert('L')
enhancer = ImageEnhance.Contrast(grayscale)
image_contrasted = enhancer.enhance(1.5)
enhancer = ImageEnhance.Brightness(image_contrasted)
image_brightened = enhancer.enhance(1.1)
image_sharpened = image_brightened.filter(ImageFilter.SHARPEN)
image_np = np.array(image_sharpened)
_, img_thresholded = cv2.threshold(image_np, 190, 255, cv2.THRESH_BINARY)
img_inverted = cv2.bitwise_not(img_thresholded)
img_resized = cv2.resize(img_inverted, None, fx=2, fy=2, interpolation=cv2.INTER_CUBIC)
processed_image_path = 'images/processed_for_ocr.png'
cv2.imwrite(processed_image_path, img_resized)