Commit e5e89c0fe8aed794d1b5df3fd74058873ac0a0a4
1 parent
8d2c61e2
Exists in
ff_mask
Option to set the ffill connectivity
Showing
2 changed files
with
42 additions
and
6 deletions
Show diff stats
invesalius/data/styles.py
@@ -1756,6 +1756,8 @@ class FFillConfig(object): | @@ -1756,6 +1756,8 @@ class FFillConfig(object): | ||
1756 | def __init__(self): | 1756 | def __init__(self): |
1757 | self.dlg_visible = False | 1757 | self.dlg_visible = False |
1758 | self.target = "2D" | 1758 | self.target = "2D" |
1759 | + self.con_2d = 4 | ||
1760 | + self.con_3d = 6 | ||
1759 | 1761 | ||
1760 | 1762 | ||
1761 | class FloodFillMaskInteractorStyle(DefaultInteractorStyle): | 1763 | class FloodFillMaskInteractorStyle(DefaultInteractorStyle): |
@@ -1804,10 +1806,10 @@ class FloodFillMaskInteractorStyle(DefaultInteractorStyle): | @@ -1804,10 +1806,10 @@ class FloodFillMaskInteractorStyle(DefaultInteractorStyle): | ||
1804 | x, y, z = self.calcultate_scroll_position(position) | 1806 | x, y, z = self.calcultate_scroll_position(position) |
1805 | 1807 | ||
1806 | if self.config.target == "3D": | 1808 | if self.config.target == "3D": |
1807 | - bstruct = np.array(generate_binary_structure(3, 1), dtype='uint8') | 1809 | + bstruct = np.array(generate_binary_structure(3, CON3D[self.config.con_3d], dtype='uint8')) |
1808 | self.viewer.slice_.do_threshold_to_all_slices() | 1810 | self.viewer.slice_.do_threshold_to_all_slices() |
1809 | else: | 1811 | else: |
1810 | - _bstruct = generate_binary_structure(2, 1) | 1812 | + _bstruct = generate_binary_structure(2, CON2D[self.config.con_2d]) |
1811 | if self.orientation == 'AXIAL': | 1813 | if self.orientation == 'AXIAL': |
1812 | bstruct = np.zeros((1, 3, 3), dtype='uint8') | 1814 | bstruct = np.zeros((1, 3, 3), dtype='uint8') |
1813 | bstruct[0] = _bstruct | 1815 | bstruct[0] = _bstruct |
@@ -1818,6 +1820,7 @@ class FloodFillMaskInteractorStyle(DefaultInteractorStyle): | @@ -1818,6 +1820,7 @@ class FloodFillMaskInteractorStyle(DefaultInteractorStyle): | ||
1818 | bstruct = np.zeros((3, 3, 1), dtype='uint8') | 1820 | bstruct = np.zeros((3, 3, 1), dtype='uint8') |
1819 | bstruct[:, :, 0] = _bstruct | 1821 | bstruct[:, :, 0] = _bstruct |
1820 | 1822 | ||
1823 | + print bstruct | ||
1821 | mask = self.viewer.slice_.current_mask.matrix[1:, 1:, 1:] | 1824 | mask = self.viewer.slice_.current_mask.matrix[1:, 1:, 1:] |
1822 | cp_mask = mask | 1825 | cp_mask = mask |
1823 | 1826 |
invesalius/gui/dialogs.py
@@ -1843,7 +1843,7 @@ def BitmapNotSameSize(): | @@ -1843,7 +1843,7 @@ def BitmapNotSameSize(): | ||
1843 | class FFillOptionsDialog(wx.Dialog): | 1843 | class FFillOptionsDialog(wx.Dialog): |
1844 | def __init__(self, config): | 1844 | def __init__(self, config): |
1845 | pre = wx.PreDialog() | 1845 | pre = wx.PreDialog() |
1846 | - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u'Floodfill'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT) | 1846 | + pre.Create(wx.GetApp().GetTopWindow(), -1, _(u'Floodfill options'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT) |
1847 | self.PostCreate(pre) | 1847 | self.PostCreate(pre) |
1848 | 1848 | ||
1849 | self.config = config | 1849 | self.config = config |
@@ -1855,22 +1855,45 @@ class FFillOptionsDialog(wx.Dialog): | @@ -1855,22 +1855,45 @@ class FFillOptionsDialog(wx.Dialog): | ||
1855 | 1855 | ||
1856 | flag_labels = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | 1856 | flag_labels = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL |
1857 | 1857 | ||
1858 | - self.target = wx.RadioBox(self, -1, _(u"Target"), | ||
1859 | - choices=[_(u"Slice"), _(u"Volume")], | ||
1860 | - style=wx.NO_BORDER | wx.HORIZONTAL) | 1858 | + self.target = wx.RadioBox(self, -1, "", |
1859 | + choices=[_(u"2D - Actual slice"), _(u"3D - Entire volume")], | ||
1860 | + style=wx.NO_BORDER | wx.VERTICAL) | ||
1861 | 1861 | ||
1862 | if self.config.target == "2D": | 1862 | if self.config.target == "2D": |
1863 | self.target.SetSelection(0) | 1863 | self.target.SetSelection(0) |
1864 | else: | 1864 | else: |
1865 | self.target.SetSelection(1) | 1865 | self.target.SetSelection(1) |
1866 | 1866 | ||
1867 | + choices2d = ["4", "8"] | ||
1868 | + choices3d = ["6", "18", "26"] | ||
1869 | + self.conect2D = wx.RadioBox(self, -1, _(u"2D Connectivity"), choices=choices2d) | ||
1870 | + self.conect3D = wx.RadioBox(self, -1, _(u"3D Connectivity"), choices=choices3d) | ||
1871 | + | ||
1872 | + try: | ||
1873 | + self.conect2D.SetSelection(choices2d.index(str(self.config.con_2d))) | ||
1874 | + except ValueError: | ||
1875 | + print "ERROR 2D" | ||
1876 | + self.conect2D.SetSelection(0) | ||
1877 | + self.config.con_2d = 4 | ||
1878 | + | ||
1879 | + try: | ||
1880 | + self.conect3D.SetSelection(choices3d.index(str(self.config.con_3d))) | ||
1881 | + except ValueError: | ||
1882 | + print "ERROR 3D" | ||
1883 | + self.conect3D.SetSelection(0) | ||
1884 | + self.config.con_3d = 6 | ||
1885 | + | ||
1867 | sizer.Add(self.target, (0, 0)) | 1886 | sizer.Add(self.target, (0, 0)) |
1887 | + sizer.Add(self.conect2D, (1, 0)) | ||
1888 | + sizer.Add(self.conect3D, (2, 0)) | ||
1868 | 1889 | ||
1869 | self.SetSizer(sizer) | 1890 | self.SetSizer(sizer) |
1870 | sizer.Fit(self) | 1891 | sizer.Fit(self) |
1871 | self.Layout() | 1892 | self.Layout() |
1872 | 1893 | ||
1873 | self.target.Bind(wx.EVT_RADIOBOX, self.OnSetTarget) | 1894 | self.target.Bind(wx.EVT_RADIOBOX, self.OnSetTarget) |
1895 | + self.conect2D.Bind(wx.EVT_RADIOBOX, self.OnSetCon2D) | ||
1896 | + self.conect3D.Bind(wx.EVT_RADIOBOX, self.OnSetCon3D) | ||
1874 | self.Bind(wx.EVT_CLOSE, self.OnClose) | 1897 | self.Bind(wx.EVT_CLOSE, self.OnClose) |
1875 | 1898 | ||
1876 | def OnSetTarget(self, evt): | 1899 | def OnSetTarget(self, evt): |
@@ -1879,6 +1902,16 @@ class FFillOptionsDialog(wx.Dialog): | @@ -1879,6 +1902,16 @@ class FFillOptionsDialog(wx.Dialog): | ||
1879 | else: | 1902 | else: |
1880 | self.config.target = "3D" | 1903 | self.config.target = "3D" |
1881 | 1904 | ||
1905 | + def OnSetCon2D(self, evt): | ||
1906 | + self.config.con_2d = int(self.conect2D.GetStringSelection()) | ||
1907 | + print self.config.con_2d | ||
1908 | + | ||
1909 | + def OnSetCon3D(self, evt): | ||
1910 | + self.config.con_3d = int(self.conect3D.GetStringSelection()) | ||
1911 | + print self.config.con_3d | ||
1912 | + | ||
1882 | def OnClose(self, evt): | 1913 | def OnClose(self, evt): |
1914 | + Publisher.sendMessage('Disable style', const.SLICE_STATE_MASK_FFILL) | ||
1883 | self.config.dlg_visible = False | 1915 | self.config.dlg_visible = False |
1884 | evt.Skip() | 1916 | evt.Skip() |
1917 | + self.Destroy() |