Commit bd86284557b90c1b1edb4d2d3ec0dae9f84416d4

Authored by Thiago Franco de Moraes
1 parent bb286f6d
Exists in ffill_segmentation

Use ww&wl

invesalius/data/styles.py
@@ -1859,6 +1859,8 @@ class FFillSegmentationConfig(object): @@ -1859,6 +1859,8 @@ class FFillSegmentationConfig(object):
1859 self.dev_min = 50 1859 self.dev_min = 50
1860 self.dev_max = 50 1860 self.dev_max = 50
1861 1861
  1862 + self.use_ww_wl = True
  1863 +
1862 1864
1863 class FloodFillSegmentInteractorStyle(DefaultInteractorStyle): 1865 class FloodFillSegmentInteractorStyle(DefaultInteractorStyle):
1864 def __init__(self, viewer): 1866 def __init__(self, viewer):
@@ -1903,19 +1905,24 @@ class FloodFillSegmentInteractorStyle(DefaultInteractorStyle): @@ -1903,19 +1905,24 @@ class FloodFillSegmentInteractorStyle(DefaultInteractorStyle):
1903 mask = self.viewer.slice_.current_mask.matrix[1:, 1:, 1:] 1905 mask = self.viewer.slice_.current_mask.matrix[1:, 1:, 1:]
1904 image = self.viewer.slice_.matrix 1906 image = self.viewer.slice_.matrix
1905 1907
1906 - v = image[z, y, x]  
1907 - print v  
1908 1908
1909 if self.config.method == 'threshold': 1909 if self.config.method == 'threshold':
  1910 + v = image[z, y, x]
1910 t0 = self.config.t0 1911 t0 = self.config.t0
1911 t1 = self.config.t1 1912 t1 = self.config.t1
  1913 +
1912 elif self.config.method == 'dynamic': 1914 elif self.config.method == 'dynamic':
1913 - print 'Method dynamic' 1915 + if self.config.use_ww_wl:
  1916 + print "Using WW&WL"
  1917 + ww = self.viewer.slice_.window_width
  1918 + wl = self.viewer.slice_.window_level
  1919 + image = get_LUT_value(image, ww, wl)
  1920 +
  1921 + v = image[z, y, x]
  1922 +
1914 t0 = v - self.config.dev_min 1923 t0 = v - self.config.dev_min
1915 t1 = v + self.config.dev_max 1924 t1 = v + self.config.dev_max
1916 1925
1917 - print v, t0, t1  
1918 -  
1919 if image[z, y, x] < t0 or image[z, y, x] > t1: 1926 if image[z, y, x] < t0 or image[z, y, x] > t1:
1920 return 1927 return
1921 1928
invesalius/gui/dialogs.py
@@ -2097,6 +2097,9 @@ class FFillSegmentationOptionsDialog(wx.Dialog): @@ -2097,6 +2097,9 @@ class FFillSegmentationOptionsDialog(wx.Dialog):
2097 self.method_threshold.SetValue(1) 2097 self.method_threshold.SetValue(1)
2098 self.config.method = 'threshold' 2098 self.config.method = 'threshold'
2099 2099
  2100 + self.use_ww_wl = wx.CheckBox(self, -1, _(u"Use WW\&WL"))
  2101 + self.use_ww_wl.SetValue(self.config.use_ww_wl)
  2102 +
2100 self.deviation_min = wx.SpinCtrl(self, -1, value='%d' % self.config.dev_min, min=0, max=10000) 2103 self.deviation_min = wx.SpinCtrl(self, -1, value='%d' % self.config.dev_min, min=0, max=10000)
2101 self.deviation_max = wx.SpinCtrl(self, -1, value='%d' % self.config.dev_max, min=0, max=10000) 2104 self.deviation_max = wx.SpinCtrl(self, -1, value='%d' % self.config.dev_max, min=0, max=10000)
2102 2105
@@ -2139,6 +2142,8 @@ class FFillSegmentationOptionsDialog(wx.Dialog): @@ -2139,6 +2142,8 @@ class FFillSegmentationOptionsDialog(wx.Dialog):
2139 sizer.AddSpacer(5) 2142 sizer.AddSpacer(5)
2140 sizer.Add(self.method_dynamic, flag=wx.LEFT, border=11) 2143 sizer.Add(self.method_dynamic, flag=wx.LEFT, border=11)
2141 sizer.AddSpacer(5) 2144 sizer.AddSpacer(5)
  2145 + sizer.Add(self.use_ww_wl, flag=wx.LEFT, border=13)
  2146 + sizer.AddSpacer(5)
2142 sizer.Add(self.deviation_min, flag=wx.LEFT, border=13) 2147 sizer.Add(self.deviation_min, flag=wx.LEFT, border=13)
2143 sizer.Add(self.deviation_max, flag=wx.LEFT, border=13) 2148 sizer.Add(self.deviation_max, flag=wx.LEFT, border=13)
2144 2149
@@ -2150,6 +2155,7 @@ class FFillSegmentationOptionsDialog(wx.Dialog): @@ -2150,6 +2155,7 @@ class FFillSegmentationOptionsDialog(wx.Dialog):
2150 2155
2151 self.Bind(wx.EVT_RADIOBUTTON, self.OnSetRadio) 2156 self.Bind(wx.EVT_RADIOBUTTON, self.OnSetRadio)
2152 self.Bind(grad.EVT_THRESHOLD_CHANGING, self.OnSlideChanged, self.threshold) 2157 self.Bind(grad.EVT_THRESHOLD_CHANGING, self.OnSlideChanged, self.threshold)
  2158 + self.use_ww_wl.Bind(wx.EVT_CHECKBOX, self.OnSetUseWWWL)
2153 self.deviation_min.Bind(wx.EVT_SPINCTRL, self.OnSetDeviation) 2159 self.deviation_min.Bind(wx.EVT_SPINCTRL, self.OnSetDeviation)
2154 self.deviation_max.Bind(wx.EVT_SPINCTRL, self.OnSetDeviation) 2160 self.deviation_max.Bind(wx.EVT_SPINCTRL, self.OnSetDeviation)
2155 self.Bind(wx.EVT_CLOSE, self.OnClose) 2161 self.Bind(wx.EVT_CLOSE, self.OnClose)
@@ -2186,6 +2192,9 @@ class FFillSegmentationOptionsDialog(wx.Dialog): @@ -2186,6 +2192,9 @@ class FFillSegmentationOptionsDialog(wx.Dialog):
2186 self.config.t1 = int(self.threshold.GetMaxValue()) 2192 self.config.t1 = int(self.threshold.GetMaxValue())
2187 print self.config.t0, self.config.t1 2193 print self.config.t0, self.config.t1
2188 2194
  2195 + def OnSetUseWWWL(self, evt):
  2196 + self.config.use_ww_wl = self.use_ww_wl.GetValue()
  2197 +
2189 def OnSetDeviation(self, evt): 2198 def OnSetDeviation(self, evt):
2190 self.config.dev_max = self.deviation_max.GetValue() 2199 self.config.dev_max = self.deviation_max.GetValue()
2191 self.config.dev_min = self.deviation_min.GetValue() 2200 self.config.dev_min = self.deviation_min.GetValue()