diff --git a/invesalius/data/floodfill.pyx b/invesalius/data/floodfill.pyx index 2659221..5b7ac6e 100644 --- a/invesalius/data/floodfill.pyx +++ b/invesalius/data/floodfill.pyx @@ -233,9 +233,9 @@ def floodfill_auto_threshold(np.ndarray[image_t, ndim=3] data, list seeds, float return out -# @cython.boundscheck(False) -# @cython.wraparound(False) -# @cython.nonecheck(False) +@cython.boundscheck(False) +@cython.wraparound(False) +@cython.nonecheck(False) 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): cdef np.ndarray[np.uint32_t, ndim=1] sizes = np.zeros(shape=(nlabels + 1), dtype=np.uint32) cdef int x, y, z diff --git a/invesalius/data/mask.py b/invesalius/data/mask.py index 6275f30..07c172d 100644 --- a/invesalius/data/mask.py +++ b/invesalius/data/mask.py @@ -347,11 +347,15 @@ class Mask(): CON3D = {6: 1, 18: 2, 26: 3} if target == '3D': + cp_mask = self.matrix.copy() matrix = self.matrix[1:, 1:, 1:] bstruct = ndimage.generate_binary_structure(3, CON3D[conn]) imask = (~(matrix > 127)) labels, nlabels = ndimage.label(imask, bstruct, output=np.uint16) + print ">>>>", nlabels + floodfill.fill_holes_automatically(matrix, labels, nlabels, size) + self.save_history(index, orientation, self.matrix.copy(), cp_mask) else: bstruct = ndimage.generate_binary_structure(2, CON2D[conn]) @@ -362,24 +366,16 @@ class Mask(): elif orientation == 'SAGITAL': matrix = self.matrix[1:, 1:, index+1] + cp_mask = matrix.copy() + imask = (~(matrix > 127)) labels, nlabels = ndimage.label(imask, bstruct, output=np.uint16) labels = labels.reshape(1, labels.shape[0], labels.shape[1]) matrix = matrix.reshape(1, matrix.shape[0], matrix.shape[1]) - - floodfill.fill_holes_automatically(matrix, labels, nlabels, size) - - # for l in xrange(nlabels): - # trues = (labels == l) - # size = trues.sum() - # print l, size - - # if size <= 1000: - # matrix[trues] = 254 - # self.was_edited = True - + floodfill.fill_holes_automatically(matrix, labels, nlabels, size) + self.save_history(index, orientation, matrix.copy(), cp_mask) def __del__(self): if self.is_shown: diff --git a/invesalius/gui/dialogs.py b/invesalius/gui/dialogs.py index 97d3ebf..1abff99 100644 --- a/invesalius/gui/dialogs.py +++ b/invesalius/gui/dialogs.py @@ -2528,8 +2528,6 @@ class FillHolesAutoDialog(wx.Dialog): self.panel2dcon.Enable(1) self.panel3dcon.Enable(0) - self.panel2dcon.conect2D_8.SetValue(1) - self.apply_btn = wx.Button(self, wx.ID_APPLY) self.close_btn = wx.Button(self, wx.ID_CLOSE) @@ -2570,7 +2568,7 @@ class FillHolesAutoDialog(wx.Dialog): else: target = "3D" conn = self.panel3dcon.GetConnSelected() - orientation = '' + orientation = 'VOLUME' data = { 'target': target, -- libgit2 0.21.2