-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage_pixels.py
55 lines (53 loc) · 1.36 KB
/
image_pixels.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
from skimage import io
import os
import matplotlib.pyplot as plt
import numpy as np
# load image into python
imagepath = os.path.join(os.getcwd(), 'face.png')
image = io.imread(imagepath)
plt.imshow(image)
plt.show()
# look at different properties of the image
Dict = {}
type(image)
image.shape
image.dtype
image.size
red_data = image[:, :, 0]
green_data = image[:, :, 1]
blue_data = image[:, :, 2]
plt.imshow(image)
plt.show()
big_big_list = []
for x in range(image.shape[0]):
for y in range(image.shape[1]):
pixel = int(''.join([str(red_data[x, y]), str(blue_data[x, y]), str(green_data[x, y])]))
if pixel not in Dict:
Dict[pixel] = 1
else:
Dict[pixel] += 1
big_big_list.append(pixel)
variance = len(Dict.keys()) // 10
keys = list(Dict.keys())
big_list = [0] * 10007
start = min(Dict.keys())
count = 0
# for item in keys:
# if item > start + variance:
# start += variance
# count += 1
# big_list[count] += Dict[item]
# for i in range(0, max(Dict.values()), variance):
plt.hist(big_big_list, bins=100)
#plt.bar(Dict.keys(), Dict.values())
#from tkinter import Tk, Canvas, PhotoImage, mainloop
#
#WIDTH, HEIGHT = 200, 100
#
#window = Tk()
#w = Canvas(window, width=WIDTH, height=HEIGHT)
# w.pack()
#img = PhotoImage(file = 'sample.png')
#w.create_image((0,0), img)
# mainloop()
# i dont know how to procees lol