forked from Seayoung277/Jaccount-Captcha-NN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gether.py
34 lines (32 loc) · 814 Bytes
/
gether.py
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
from scipy import io
from PIL import Image
data = []
for imageIndex in range(10000):
imdata = []
imageName = "./words/%d." %imageIndex
image = Image.open(imageName + "png")
pimw = image.load()
#print(type(pimw[0, 0]))
for row in range(40):
for col in range(20):
if(pimw[col, row]==255):
imdata.append(0.0)
else:
imdata.append(1.0)
data.append(imdata)
io.savemat('trainData', {'train_data':data})
data = []
for imageIndex in range(2000):
imdata = []
imageName = "./words/%d." %(imageIndex+10000)
image = Image.open(imageName + "png")
pimw = image.load()
#print(type(pimw[0, 0]))
for row in range(40):
for col in range(20):
if(pimw[col, row]==255):
imdata.append(0.0)
else:
imdata.append(1.0)
data.append(imdata)
io.savemat('validationData', {'validation_data':data})