-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave.py
62 lines (43 loc) · 1.55 KB
/
save.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import cv2
import numpy as np
import check
def save(path,store):
rep = 0
use = 0
name = path[0:path.find('.')]
img = cv2.imread('Images\\' + path)
master = cv2.imread("Saves\\master.png")
if(master is None):
master = []
master = list(master)
max_ind = int(open("Saves\\max_ind.txt",'r').read())
replace = ""
for i in range(0,len(img)-32,32):
for j in range(0,len(img[0])-32,32):
sections = img[i:i+32]
save = []
for section in sections:
save.append(section[j:j+32])
c = check.check(save,master,store)
#c = -1
if(c == -1):
h = hash(str(save))
if(not h in store):
store[h] = []
store[h].append(max_ind)
master.extend(save)
replace += str(max_ind) + " "
max_ind += 1
use += 32*32
else:
rep += 32*32
replace += str(c) + " "
replace += "\n"
cv2.imwrite("Saves\\master.png",np.array(master),[cv2.IMWRITE_PNG_COMPRESSION, 3])
file = open("New Images\\" + name + ".rna",'w')
file.write(replace)
file.close()
file = open("Saves\\max_ind.txt",'w')
file.write(str(max_ind))
file.close()
print(name,"SAVED",rep,"USED",use)