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

from PIL import Image
import pytesseract

text = 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")

你可能感兴趣的:(Python3)