Python中使用tesserocr时如何确定适合的阀值

在进行爬虫识别图形验证码时,为提高准确度,需要自己进行灰度,二值化等操作。
阀值的不同,对结果也会有较大影响,所以,我想问:如何确定阀值的最佳值或范围。

import tesserocr
from PIL import Image
image = Image.open('F:/code.jpg')
image=image.convert('L') 
threshold=120  #这个阀值是我一点点实验出来的
table=[]
for i in range(256):
    if i<threshold:
        table.append(0)
    else:
        table.append(1)
image=image.point(table,'1')
result = tesserocr.image_to_text(image)
print(result)

dJuh

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 以帮助更多的人 ^-^