@@ -50,6 +50,8 @@ def save_lab_image(path, lab_arr):
50
50
io .imsave (path , rgb_arr )
51
51
52
52
def make_cluster (self , h , w ):
53
+ h = int (h )
54
+ w = int (w )
53
55
return Cluster (h , w ,
54
56
self .data [h ][w ][0 ],
55
57
self .data [h ][w ][1 ],
@@ -85,9 +87,9 @@ def get_gradient(self, h, w):
85
87
if h + 1 >= self .image_height :
86
88
h = self .image_height - 2
87
89
88
- gradient = self .data [w + 1 ][h + 1 ][0 ] - self .data [w ][ h ][0 ] + \
89
- self .data [w + 1 ][h + 1 ][1 ] - self .data [w ][ h ][1 ] + \
90
- self .data [w + 1 ][h + 1 ][2 ] - self .data [w ][ h ][2 ]
90
+ gradient = self .data [h + 1 ][w + 1 ][0 ] - self .data [h ][ w ][0 ] + \
91
+ self .data [h + 1 ][w + 1 ][1 ] - self .data [h ][ w ][1 ] + \
92
+ self .data [h + 1 ][w + 1 ][2 ] - self .data [h ][ w ][2 ]
91
93
return gradient
92
94
93
95
def move_clusters (self ):
@@ -134,9 +136,9 @@ def update_cluster(self):
134
136
sum_h += p [0 ]
135
137
sum_w += p [1 ]
136
138
number += 1
137
- _h = sum_h / number
138
- _w = sum_w / number
139
- cluster .update (_h , _w , self .data [_h ][_w ][0 ], self .data [_h ][_w ][1 ], self .data [_h ][_w ][2 ])
139
+ _h = int ( sum_h / number )
140
+ _w = int ( sum_w / number )
141
+ cluster .update (_h , _w , self .data [_h ][_w ][0 ], self .data [_h ][_w ][1 ], self .data [_h ][_w ][2 ])
140
142
141
143
def save_current_image (self , name ):
142
144
image_arr = np .copy (self .data )
0 commit comments