@@ -55,9 +55,9 @@ def make_cluster(self, h, w):
55
55
self .data [h ][w ][1 ],
56
56
self .data [h ][w ][2 ])
57
57
58
- def __init__ (self , filename , K ):
58
+ def __init__ (self , filename , K , M ):
59
59
self .K = K
60
- self .M = 40
60
+ self .M = M
61
61
62
62
self .data = self .open_image (filename )
63
63
self .image_height = self .data .shape [0 ]
@@ -155,13 +155,25 @@ def iterate_10times(self):
155
155
self .move_clusters ()
156
156
for i in trange (10 ):
157
157
self .assignment ()
158
- name = 'slic_{}_assignment_M{}_K{}.png' .format (i , self .M , self .K )
159
- self .save_current_image (name )
160
158
self .update_cluster ()
161
- name = 'slic_{}_update_M{}_K{ }.png' .format (i , self .M , self .K )
159
+ name = 'lenna_M{m}_K{k}_loop{loop }.png' .format (loop = i , m = self .M , k = self .K )
162
160
self .save_current_image (name )
163
161
164
162
165
163
if __name__ == '__main__' :
166
- p = SLICProcessor ('Lenna.png' , 200 )
164
+ p = SLICProcessor ('Lenna.png' , 200 , 40 )
165
+ p .iterate_10times ()
166
+ p = SLICProcessor ('Lenna.png' , 300 , 40 )
167
+ p .iterate_10times ()
168
+ p = SLICProcessor ('Lenna.png' , 500 , 40 )
169
+ p .iterate_10times ()
170
+ p = SLICProcessor ('Lenna.png' , 1000 , 40 )
171
+ p .iterate_10times ()
172
+ p = SLICProcessor ('Lenna.png' , 200 , 5 )
173
+ p .iterate_10times ()
174
+ p = SLICProcessor ('Lenna.png' , 300 , 5 )
175
+ p .iterate_10times ()
176
+ p = SLICProcessor ('Lenna.png' , 500 , 5 )
167
177
p .iterate_10times ()
178
+ p = SLICProcessor ('Lenna.png' , 1000 , 5 )
179
+ p .iterate_10times ()
0 commit comments