当前位置: 代码迷 >> 综合 >> pytesseract 获取图片上字符串,及增加亮度,色感,对比度,锐度
  详细解决方案

pytesseract 获取图片上字符串,及增加亮度,色感,对比度,锐度

热度:97   发布时间:2023-11-18 14:12:43.0
from PIL import Image
import pytesseracttext = pytesseract.image_to_string(Image.open("./pic/pythontest.png"))
print(text)

def pic_dispose(x):

    image = Image.open(x)
    image.show()
    #亮度
    enh_bri = ImageEnhance.Brightness(image)
    brightness = 1.8
    image_brightened = enh_bri.enhance(brightness)
    image_brightened.show()

    #色感
    enh_col = ImageEnhance.Color(image)
    color = 1.5
    image_colored = enh_col.enhance(color)
    image_colored.show()

    # 对比度增强
    enh_con = ImageEnhance.Contrast(image)
    contrast = 1.5
    image_contrasted = enh_con.enhance(contrast)
    image_contrasted.show()

    # 锐度增强
    enh_sha = ImageEnhance.Sharpness(image)
    sharpness = 3.0
    image_sharped = enh_sha.enhance(sharpness)
    image_sharped.show()

pic_dispose("./pic/pythontest.png")