I wanted to carry out a small personal project that consists of extracting text from an image and translating it into other languages, all using python.But I have problems when I want to extract the texts from the images. For example, I want to extract the text from this image:
Image used as proof
And this is what it throws at me:
yO
DONT You KNOW
WHO I AM? I’M ED
ROTHSTAYLOR!
THE HORRIBLE
GOOD-FOR-NOTHING,
‘ED ROTHSTAYLOR!
bL—) wyscre |
AROUND ME?!
This is the code:
import cv2
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r'C:Program FilesTesseract-OCRtesseract'
img = cv2.imread('webtoon13.png')
gris = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
print(pytesseract.image_to_string(gris))
Is there any way to improve the result?
Thanks in advance.
I have already tried image smoothing and used the .threshold() method of the cv2 library.
I expected improvements in the result, but no, it simply got worse, it didn’t even detect the text well anymore. The best result I have had so far is converting the image to a grayscale, but it still does not detect the text well (or it simply does not detect all the text).
milou is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.