I have an image that is converted to a numpy array
np_image = np.array(Image.open(filename))
I am attempting OCR using pytesseract, but the ocr fails when the text is red or yellow and so I want all text to be black.
I am breaking down the image into snippets as I know where the individual text elements appear
As you can see from the code below, I have attempted to find coloured pixels and and convert them to black, but it does not work
snippet = np_image[top: bottom, field.left: field.right].copy()
for row in snippet:
for pixel in row:
test = [rgb for rgb in pixel[:-1]]
test.sort()
if test[0] > 190 and test[2] < 100:
pixel = [0, 0, 0, 255]
text = pytesseract.image_to_string(snippet)
What should I do?