How to make text clear and sharp on image using OpenCV

Viewed 4310

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

1 Answers
Related