-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·83 lines (70 loc) · 2.08 KB
/
Copy pathmain.py
File metadata and controls
executable file
·83 lines (70 loc) · 2.08 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/python3
import PIL
from PIL import Image
import os
while True:
file_path = input("Enter image file path: ")
ext = os.path.splitext(file_path)[-1].lower()
pil_image = PIL.Image.open(file_path)
if ext == ".png":
pilimg = PIL.Image.open(file_path)
wid, hei = pilimg.size
image_res = str(wid)+"x"+str(hei)
if image_res == "100x100":
break
else:
print()
print("Image must be 100x100 pixels.")
else:
print()
print("Invalid file. Select a .png image.")
pixelarray = [0, 0]
color0 = []
color1 = []
color2 = []
color3 = []
color4 = []
color5 = []
while pixelarray <= [99, 99]:
current_pixel = (pixelarray[0], pixelarray[1])
pixel_color = pil_image.getpixel(current_pixel)
if pixel_color[0] >= 0 and pixel_color[0] <= 42:
color0.append(current_pixel)
print("appended1")
elif pixel_color[0] >= 43 and pixel_color[0] <= 84:
color1.append(current_pixel)
print("appended2")
elif pixel_color[0] >= 85 and pixel_color[0] <= 126:
color2.append(current_pixel)
elif pixel_color[0] >= 127 and pixel_color[0] <= 168:
color3.append(current_pixel)
elif pixel_color[0] >= 168 and pixel_color[0] <= 210:
color4.append(current_pixel)
elif pixel_color[0] >= 211 and pixel_color[0] <= 255:
color5.append(current_pixel)
if pixelarray[0] < 99:
pixelarray[0] += 1
elif pixelarray[1] == 99:
break
else:
pixelarray[1] += 1
pixelarray[0] = 0
print(pixelarray)
print("------------------------ color0 ------------------------")
print(color0)
print()
print("------------------------ color1 ------------------------")
print(color1)
print()
print("------------------------ color2 ------------------------")
print(color2)
print()
print("------------------------ color3 ------------------------")
print(color3)
print()
print("------------------------ color4 ------------------------")
print(color4)
print()
print("------------------------ color5 ------------------------")
print(color5)
print()