Commit bd86284557b90c1b1edb4d2d3ec0dae9f84416d4
1 parent
bb286f6d
Exists in
ffill_segmentation
Use ww&wl
Showing
2 changed files
with
21 additions
and
5 deletions
Show diff stats
invesalius/data/styles.py
| ... | ... | @@ -1859,6 +1859,8 @@ class FFillSegmentationConfig(object): |
| 1859 | 1859 | self.dev_min = 50 |
| 1860 | 1860 | self.dev_max = 50 |
| 1861 | 1861 | |
| 1862 | + self.use_ww_wl = True | |
| 1863 | + | |
| 1862 | 1864 | |
| 1863 | 1865 | class FloodFillSegmentInteractorStyle(DefaultInteractorStyle): |
| 1864 | 1866 | def __init__(self, viewer): |
| ... | ... | @@ -1903,19 +1905,24 @@ class FloodFillSegmentInteractorStyle(DefaultInteractorStyle): |
| 1903 | 1905 | mask = self.viewer.slice_.current_mask.matrix[1:, 1:, 1:] |
| 1904 | 1906 | image = self.viewer.slice_.matrix |
| 1905 | 1907 | |
| 1906 | - v = image[z, y, x] | |
| 1907 | - print v | |
| 1908 | 1908 | |
| 1909 | 1909 | if self.config.method == 'threshold': |
| 1910 | + v = image[z, y, x] | |
| 1910 | 1911 | t0 = self.config.t0 |
| 1911 | 1912 | t1 = self.config.t1 |
| 1913 | + | |
| 1912 | 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 | 1923 | t0 = v - self.config.dev_min |
| 1915 | 1924 | t1 = v + self.config.dev_max |
| 1916 | 1925 | |
| 1917 | - print v, t0, t1 | |
| 1918 | - | |
| 1919 | 1926 | if image[z, y, x] < t0 or image[z, y, x] > t1: |
| 1920 | 1927 | return |
| 1921 | 1928 | ... | ... |
invesalius/gui/dialogs.py
| ... | ... | @@ -2097,6 +2097,9 @@ class FFillSegmentationOptionsDialog(wx.Dialog): |
| 2097 | 2097 | self.method_threshold.SetValue(1) |
| 2098 | 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 | 2103 | self.deviation_min = wx.SpinCtrl(self, -1, value='%d' % self.config.dev_min, min=0, max=10000) |
| 2101 | 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 | 2142 | sizer.AddSpacer(5) |
| 2140 | 2143 | sizer.Add(self.method_dynamic, flag=wx.LEFT, border=11) |
| 2141 | 2144 | sizer.AddSpacer(5) |
| 2145 | + sizer.Add(self.use_ww_wl, flag=wx.LEFT, border=13) | |
| 2146 | + sizer.AddSpacer(5) | |
| 2142 | 2147 | sizer.Add(self.deviation_min, flag=wx.LEFT, border=13) |
| 2143 | 2148 | sizer.Add(self.deviation_max, flag=wx.LEFT, border=13) |
| 2144 | 2149 | |
| ... | ... | @@ -2150,6 +2155,7 @@ class FFillSegmentationOptionsDialog(wx.Dialog): |
| 2150 | 2155 | |
| 2151 | 2156 | self.Bind(wx.EVT_RADIOBUTTON, self.OnSetRadio) |
| 2152 | 2157 | self.Bind(grad.EVT_THRESHOLD_CHANGING, self.OnSlideChanged, self.threshold) |
| 2158 | + self.use_ww_wl.Bind(wx.EVT_CHECKBOX, self.OnSetUseWWWL) | |
| 2153 | 2159 | self.deviation_min.Bind(wx.EVT_SPINCTRL, self.OnSetDeviation) |
| 2154 | 2160 | self.deviation_max.Bind(wx.EVT_SPINCTRL, self.OnSetDeviation) |
| 2155 | 2161 | self.Bind(wx.EVT_CLOSE, self.OnClose) |
| ... | ... | @@ -2186,6 +2192,9 @@ class FFillSegmentationOptionsDialog(wx.Dialog): |
| 2186 | 2192 | self.config.t1 = int(self.threshold.GetMaxValue()) |
| 2187 | 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 | 2198 | def OnSetDeviation(self, evt): |
| 2190 | 2199 | self.config.dev_max = self.deviation_max.GetValue() |
| 2191 | 2200 | self.config.dev_min = self.deviation_min.GetValue() | ... | ... |