Commit cf46a8eba084b51ebe36e88625c1e7ec3051bf0e
1 parent
6d417076
Exists in
fill_holes_auto
added ctrl-z and ctrl-y
Showing
3 changed files
with
12 additions
and
18 deletions
Show diff stats
invesalius/data/floodfill.pyx
... | ... | @@ -233,9 +233,9 @@ def floodfill_auto_threshold(np.ndarray[image_t, ndim=3] data, list seeds, float |
233 | 233 | return out |
234 | 234 | |
235 | 235 | |
236 | -# @cython.boundscheck(False) | |
237 | -# @cython.wraparound(False) | |
238 | -# @cython.nonecheck(False) | |
236 | +@cython.boundscheck(False) | |
237 | +@cython.wraparound(False) | |
238 | +@cython.nonecheck(False) | |
239 | 239 | def fill_holes_automatically(np.ndarray[mask_t, ndim=3] mask, np.ndarray[np.uint16_t, ndim=3] labels, unsigned int nlabels, unsigned int max_size): |
240 | 240 | cdef np.ndarray[np.uint32_t, ndim=1] sizes = np.zeros(shape=(nlabels + 1), dtype=np.uint32) |
241 | 241 | cdef int x, y, z | ... | ... |
invesalius/data/mask.py
... | ... | @@ -347,11 +347,15 @@ class Mask(): |
347 | 347 | CON3D = {6: 1, 18: 2, 26: 3} |
348 | 348 | |
349 | 349 | if target == '3D': |
350 | + cp_mask = self.matrix.copy() | |
350 | 351 | matrix = self.matrix[1:, 1:, 1:] |
351 | 352 | bstruct = ndimage.generate_binary_structure(3, CON3D[conn]) |
352 | 353 | |
353 | 354 | imask = (~(matrix > 127)) |
354 | 355 | labels, nlabels = ndimage.label(imask, bstruct, output=np.uint16) |
356 | + print ">>>>", nlabels | |
357 | + floodfill.fill_holes_automatically(matrix, labels, nlabels, size) | |
358 | + self.save_history(index, orientation, self.matrix.copy(), cp_mask) | |
355 | 359 | else: |
356 | 360 | bstruct = ndimage.generate_binary_structure(2, CON2D[conn]) |
357 | 361 | |
... | ... | @@ -362,24 +366,16 @@ class Mask(): |
362 | 366 | elif orientation == 'SAGITAL': |
363 | 367 | matrix = self.matrix[1:, 1:, index+1] |
364 | 368 | |
369 | + cp_mask = matrix.copy() | |
370 | + | |
365 | 371 | imask = (~(matrix > 127)) |
366 | 372 | labels, nlabels = ndimage.label(imask, bstruct, output=np.uint16) |
367 | 373 | |
368 | 374 | labels = labels.reshape(1, labels.shape[0], labels.shape[1]) |
369 | 375 | matrix = matrix.reshape(1, matrix.shape[0], matrix.shape[1]) |
370 | 376 | |
371 | - | |
372 | - floodfill.fill_holes_automatically(matrix, labels, nlabels, size) | |
373 | - | |
374 | - # for l in xrange(nlabels): | |
375 | - # trues = (labels == l) | |
376 | - # size = trues.sum() | |
377 | - # print l, size | |
378 | - | |
379 | - # if size <= 1000: | |
380 | - # matrix[trues] = 254 | |
381 | - # self.was_edited = True | |
382 | - | |
377 | + floodfill.fill_holes_automatically(matrix, labels, nlabels, size) | |
378 | + self.save_history(index, orientation, matrix.copy(), cp_mask) | |
383 | 379 | |
384 | 380 | def __del__(self): |
385 | 381 | if self.is_shown: | ... | ... |
invesalius/gui/dialogs.py
... | ... | @@ -2528,8 +2528,6 @@ class FillHolesAutoDialog(wx.Dialog): |
2528 | 2528 | self.panel2dcon.Enable(1) |
2529 | 2529 | self.panel3dcon.Enable(0) |
2530 | 2530 | |
2531 | - self.panel2dcon.conect2D_8.SetValue(1) | |
2532 | - | |
2533 | 2531 | self.apply_btn = wx.Button(self, wx.ID_APPLY) |
2534 | 2532 | self.close_btn = wx.Button(self, wx.ID_CLOSE) |
2535 | 2533 | |
... | ... | @@ -2570,7 +2568,7 @@ class FillHolesAutoDialog(wx.Dialog): |
2570 | 2568 | else: |
2571 | 2569 | target = "3D" |
2572 | 2570 | conn = self.panel3dcon.GetConnSelected() |
2573 | - orientation = '' | |
2571 | + orientation = 'VOLUME' | |
2574 | 2572 | |
2575 | 2573 | data = { |
2576 | 2574 | 'target': target, | ... | ... |