您的位置:首页 > 编程语言 > Python开发

selenium python 图像二值化

2017-10-24 09:41 141 查看

1. 使用PIL

# coding:utf-8
# coding:cp936

# 二值化处理

from selenium import webdriver
from PIL import Image
from time import sleep
# broswer = webdriver.Chrome()
im = Image.open(r'C:\picture6.png')

imgry = im.convert('L')
# imgry.show()

threshold = 200
table = []
for i in range(256):
if i < threshold:
table.append(1)
else:
table.append(0)
out = imgry.point(table, '1')
out.save(r'C:\ocr1.png')


参考:

Python验证码识别:利用pytesser识别简单图形验证码
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: