Commit de653d326ee28fc452a65361292d6a161da7357f
1 parent
daaeeb87
Exists in
mask_greatest_component
Added Intesection and XOR
Showing
3 changed files
with
18 additions
and
4 deletions
Show diff stats
invesalius/constants.py
invesalius/data/slice_.py
... | ... | @@ -1222,7 +1222,9 @@ class Slice(object): |
1222 | 1222 | |
1223 | 1223 | def do_boolean_op(self, op, m1, m2): |
1224 | 1224 | name_ops = {const.BOOLEAN_UNION: _(u"Union"), |
1225 | - const.BOOLEAN_DIFF: _(u"Diff")} | |
1225 | + const.BOOLEAN_DIFF: _(u"Diff"), | |
1226 | + const.BOOLEAN_AND: _(u"Intersection"), | |
1227 | + const.BOOLEAN_XOR: _(u"XOR")} | |
1226 | 1228 | |
1227 | 1229 | |
1228 | 1230 | name = u"%s_%s_%s" % (name_ops[op], m1.name, m2.name) |
... | ... | @@ -1250,6 +1252,12 @@ class Slice(object): |
1250 | 1252 | elif op == const.BOOLEAN_DIFF: |
1251 | 1253 | m[:] = ((m1 > 2) - (m2 > 2)) * 255 |
1252 | 1254 | |
1255 | + elif op == const.BOOLEAN_AND: | |
1256 | + m[:] = ((m1 > 2) & (m2 > 2)) * 255 | |
1257 | + | |
1258 | + elif op == const.BOOLEAN_XOR: | |
1259 | + m[:] = numpy.logical_xor((m1 > 2), (m2 > 2)) * 255 | |
1260 | + | |
1253 | 1261 | future_mask.was_edited = True |
1254 | 1262 | self._add_mask_into_proj(future_mask) |
1255 | 1263 | ... | ... |
invesalius/gui/dialogs.py
... | ... | @@ -1407,7 +1407,9 @@ class MaskBooleanDialog(wx.Dialog): |
1407 | 1407 | self.mask2.SetSelection(0) |
1408 | 1408 | |
1409 | 1409 | op_choices = ((u"Union", const.BOOLEAN_UNION), |
1410 | - (u"Difference", const.BOOLEAN_DIFF)) | |
1410 | + (u"Difference", const.BOOLEAN_DIFF), | |
1411 | + (u"Intersection", const.BOOLEAN_AND), | |
1412 | + (u"XOR", const.BOOLEAN_XOR)) | |
1411 | 1413 | self.op_boolean = wx.ComboBox(self, -1, op_choices[0][0], choices=[]) |
1412 | 1414 | |
1413 | 1415 | for n, i in op_choices: |
... | ... | @@ -1443,6 +1445,8 @@ class MaskBooleanDialog(wx.Dialog): |
1443 | 1445 | m1 = self.mask1.GetClientData(self.mask1.GetSelection()) |
1444 | 1446 | m2 = self.mask2.GetClientData(self.mask2.GetSelection()) |
1445 | 1447 | |
1446 | - print op, m1.name, m2.name | |
1447 | - | |
1448 | 1448 | Publisher.sendMessage('Do boolean operation', (op, m1, m2)) |
1449 | + Publisher.sendMessage('Reload actual slice') | |
1450 | + | |
1451 | + self.Close() | |
1452 | + self.Destroy() | ... | ... |