0
votes

i want to extract only blue color text in image uisng tesseract ocr. please help me regarding this.

basic code i tried:

import PIL.Image import cv import pytesseract,re my_image = PIL.Image.open(r"C:\Users\sony\Desktop\Cap_sample\MicrosoftTeams-image (4).png") pytesseract.pytesseract.tesseract_cmd = (r'C:\Program Files\Tesseract-OCR\tesseract.exe') my_image_text = pytesseract.image_to_string(my_image) print(my_image_text)

1
provide also input image.user898678

1 Answers

0
votes

one possible solution would be to use a mask to get image with blue colors only and then extract text

try using something like

blueLower = np.array([100, 67, 0], dtype = "uint8")
blueUpper = np.array([255, 128, 50], dtype = "uint8")
blue = cv2.inRange(img, blueLower, blueUpper)

this will get a mask of where the blue color is present in the image and then maybe use tesseract on it. on the mask to get text