pythonPIL模块的基本使用-创新互联
PIL基本功能介绍
创新互联主要从事成都网站设计、网站制作、网页设计、企业做网站、公司建网站等业务。立足成都服务康保,十多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792from PIL import Image from PIL import ImageEnhance img = Image.open(r'E:\img\f1.png') img.show() #图像二值化 img = img.convert('L') # 图像放大 img = img.resize((img.width * int(3), img.height * int(4)), Image.ANTIALIAS) # # 对比度增强 enh_con = ImageEnhance.Contrast(img) contrast = 2 img_contrasted = enh_con.enhance(contrast) # 亮度增强 enh_bri = ImageEnhance.Brightness(img_contrasted) brightness = 2.5 image_brightened = enh_bri.enhance(brightness) #色度增强 enh_col = ImageEnhance.Color(img) color = 50 image_colored = enh_col.enhance(color) # # 锐度增强 enh_sha = ImageEnhance.Sharpness(img) sharpness = 2 image_sharped = enh_sha.enhance(sharpness) image_sharped.save(r'E:\img\f22.png', dpi=(300, 300), quality=95) # image_sharped.save(r'E:\img\f22.png') # 图片汉字识别 img2 = Image.open(r'E:\img\f22.png') code2 = pytesseract.image_to_string(img2, lang='chi_sim') # print(code2) # 图片裁剪 image_cro = Image.open(r'E:\img\f24.png') image_cropped = image_cro.crop(res) image_cropped.save(u'E:\img\\f25.png')
分享标题:pythonPIL模块的基本使用-创新互联
网址分享:http://scyanting.com/article/codghp.html