I am trying to improve an image in order to making the text more readable for OCR, but the problem is that some images have some missing pixels and OCR doesn't recognized it.
Here is my code:
import cv2 as cv
import pytesseract
import numpy as np
img = cv.imread("image1.jpeg")
img = cv.cvtColor(img, cv.COLOR_RGB2GRAY)
threshold = cv.adaptiveThreshold(img, 255, cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY, 57, 13)
x = 255 - threshold
kernel = np.ones((3, 3),np.uint8)
closing = cv.morphologyEx(x, cv.MORPH_CLOSE, kernel)
captcha = pytesseract.image_to_string(closing, config="--psm 3")
print(captcha)
cv.imshow('close', closing)
cv.imshow('thresh', threshold)
cv.waitKey(0)
cv.destroyAllWindows()
This is the original image
This is threshold image
And this is the result after using closing morph
For some reason OCR returns the string le eth g
Any idea of how can I improve my code?



