-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpriority.py
28 lines (25 loc) · 898 Bytes
/
priority.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
import os
import numpy as np
from PIL import Image
path = os.getcwd()
res = 7475
full = np.zeros((res, res))
while True:
fn = input("Enter file name: ") + ".png"
if fn == "stop.png":
break
elif fn == "save.png":
Image.fromarray(full.astype(bool)).save(os.path.join(path, "p", "_save.png"))
continue
elif fn == "load.png":
full = Image.open(os.path.join(path, "p", "_save.png"))
continue
elif not os.path.exists(os.path.join(path, fn)):
print(fn + " does not exist, try again.")
continue
old = Image.open(os.path.join(path, fn))
new = np.subtract(old,np.minimum(full,old))
print(str(round(100*(np.sum(new) / (np.sum(old))),2)) + "%...")
full = np.maximum(full, new)
Image.fromarray(new.astype(bool)).save(os.path.join(path, "p", fn))
os.remove(os.path.join(path, fn))