Python实现图片识别功能的示例分享


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

from pytesser import *

from PIL import Image, ImageEnhance

im = Image.open('D:\Python27\Lib\site-packages\pytesser\phototest.tif')

im2 = Image.open(r'D:\Python27\Lib\site-packages\pytesser\fnord.tif','r')

im3 = Image.open(r'F:\PROJECT\python\code\Study_1\src\20170424\cp.jpg','r') #文件读写模式以防报错

#图片处理1::黑白处理

enhancer = ImageEnhance.Contrast(im3)

image2 = enhancer.enhance(5)

image2.show()

print image_to_string(image2)

#图片处理2: 降噪处理

imgry = im3.convert('L'#灰度处理

#灰度处理基础上二值化处理

threshold = 140

table = []

for i in range(256):

  if i < threshold:

    table.append(0)

  else:

    table.append(1)

out = imgry.point(table, '1')

out.show()

text = image_to_string(out)

if text.isspace() :

  print "FAILE"

else:

  print text

#print text

以上就是Python实现图片识别功能的示例分享的详细内容,更多文章请关注木庄网络博客!!

返回前面的内容

相关阅读 >>

Python中str.format()详解_Python

Python字符串是可变类型吗

Python怎么截图

Python安装流程指南

Python接口使用opencv的方法

Python如何使用列表

Python属于开源语言吗

Python访问限制私有还是公有的介绍(附示例)

Python如何取set元素个数

Python如何生成exe文件

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...