# -*- encoding:utf-8 -*- ''' @Author : dingjiawen @Date : 2023/12/11 19:35 @Usage : @Desc : ''' import tesserocr from PIL import Image import numpy as np image = Image.open('image.png') print(np.array(image).shape) print(image.mode) image = image.convert('L') threshold = 100 array = np.array(image) array = np.where(array > threshold, 255, 0) image = Image.fromarray(array.astype('uint8')) # image.show() print(tesserocr.image_to_text(image))