Richie Zakaria
Richie Zakaria

Reputation: 91

How to make text clear and sharp on image using OpenCV

So I want to OCR an image that has a text

"Here is the image"

but the output is always strange and does not match the text in the picture.
So I decided to change the image properties.
I change it like this :

image = cv2.imread("./image_frames/frame473.png")

def get_grayscale(image):
    return cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
def blur(image):
    return cv2.medianBlur(image,3)
def thresholding(image):
    return cv2.threshold(image, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]

gray = get_grayscale(image)
# edges = cv2.Canny(gray, 60, 120)
thre= thresholding(blur)
blur = blur(thre)

cv2.imwrite("frame2.png", blur)

The result is like this

the result is like this

even though I changed it, the OCR result is still the same result. Anyone have a solution ?
I really appreciate your answer,thanks in advance

Upvotes: 5

Views: 10756

Answers (1)

Mayur Deshmukh
Mayur Deshmukh

Reputation: 392

You can try applying preprocessing steps given in -

https://tesseract-ocr.github.io/tessdoc/ImproveQuality

And then give the preprocessed image to Google Tesseract OCR. I'm sure that it will recognize the text.

Upvotes: 3

Related Questions