-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_analysis.py
More file actions
40 lines (27 loc) · 907 Bytes
/
Copy pathdata_analysis.py
File metadata and controls
40 lines (27 loc) · 907 Bytes
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
29
30
31
32
33
34
35
36
37
38
39
40
import pytesseract
from PIL import Image
from PIL import ImageEnhance, ImageFilter
import numpy as np
import os
import glob
list = sorted(glob.glob("*.png"))
for pic in list:
## open image and make it larger
image = Image.open(pic)
(width, height) = (image.width * 3, image.height * 3)
image = image.resize((width, height))
## apply black and white filter
# image = image.convert('L')
## apply image enhancement
# image = image.filter(ImageFilter.MinFilter)
# sharpness = ImageEnhance.Sharpness(image)
# image = sharpness.enhance(15)
# contrast = ImageEnhance.Contrast(image)
# image = contrast.enhance(1.2)
# image = image.convert('L')
# dispaly image if necessary
#image.show()
# recognize text in the image using pytesseract
text = pytesseract.image_to_string(image)
# print the text
print(text)