-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.py
More file actions
33 lines (24 loc) · 892 Bytes
/
Node.py
File metadata and controls
33 lines (24 loc) · 892 Bytes
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
import numpy as np
class Node:
frequences = np.zeros((256,), dtype=int)
def __init__(self, data=None, frequence=None, r=None, l=None, heap=[]):
self.H = heap
self.data = data
self.right = r
self.left = l
self.frequence = frequence
# show the frequence of the pixels in the image
def setFrequencePixels(self, image, height, weight):
for i in range(height):
for j in range(weight):
self.frequences[image[i][j]] += 1
# ..........................................
# store the nodes in an array
def storeNode(self):
for i in range(256):
#..................data, frequence of pixel
self.H.append(Node(i, self.frequences[i]))
# .............................................
def returnArrayNode(self):
self.storeNode()
return self.H