From bd86284557b90c1b1edb4d2d3ec0dae9f84416d4 Mon Sep 17 00:00:00 2001 From: Thiago Franco de Moraes Date: Fri, 2 Sep 2016 15:46:38 -0300 Subject: [PATCH] Use ww&wl --- invesalius/data/styles.py | 17 ++++++++++++----- invesalius/gui/dialogs.py | 9 +++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/invesalius/data/styles.py b/invesalius/data/styles.py index a69e54a..5677cc0 100644 --- a/invesalius/data/styles.py +++ b/invesalius/data/styles.py @@ -1859,6 +1859,8 @@ class FFillSegmentationConfig(object): self.dev_min = 50 self.dev_max = 50 + self.use_ww_wl = True + class FloodFillSegmentInteractorStyle(DefaultInteractorStyle): def __init__(self, viewer): @@ -1903,19 +1905,24 @@ class FloodFillSegmentInteractorStyle(DefaultInteractorStyle): mask = self.viewer.slice_.current_mask.matrix[1:, 1:, 1:] image = self.viewer.slice_.matrix - v = image[z, y, x] - print v if self.config.method == 'threshold': + v = image[z, y, x] t0 = self.config.t0 t1 = self.config.t1 + elif self.config.method == 'dynamic': - print 'Method dynamic' + if self.config.use_ww_wl: + print "Using WW&WL" + ww = self.viewer.slice_.window_width + wl = self.viewer.slice_.window_level + image = get_LUT_value(image, ww, wl) + + v = image[z, y, x] + t0 = v - self.config.dev_min t1 = v + self.config.dev_max - print v, t0, t1 - if image[z, y, x] < t0 or image[z, y, x] > t1: return diff --git a/invesalius/gui/dialogs.py b/invesalius/gui/dialogs.py index 8e471f4..6a74ac6 100644 --- a/invesalius/gui/dialogs.py +++ b/invesalius/gui/dialogs.py @@ -2097,6 +2097,9 @@ class FFillSegmentationOptionsDialog(wx.Dialog): self.method_threshold.SetValue(1) self.config.method = 'threshold' + self.use_ww_wl = wx.CheckBox(self, -1, _(u"Use WW\&WL")) + self.use_ww_wl.SetValue(self.config.use_ww_wl) + self.deviation_min = wx.SpinCtrl(self, -1, value='%d' % self.config.dev_min, min=0, max=10000) self.deviation_max = wx.SpinCtrl(self, -1, value='%d' % self.config.dev_max, min=0, max=10000) @@ -2139,6 +2142,8 @@ class FFillSegmentationOptionsDialog(wx.Dialog): sizer.AddSpacer(5) sizer.Add(self.method_dynamic, flag=wx.LEFT, border=11) sizer.AddSpacer(5) + sizer.Add(self.use_ww_wl, flag=wx.LEFT, border=13) + sizer.AddSpacer(5) sizer.Add(self.deviation_min, flag=wx.LEFT, border=13) sizer.Add(self.deviation_max, flag=wx.LEFT, border=13) @@ -2150,6 +2155,7 @@ class FFillSegmentationOptionsDialog(wx.Dialog): self.Bind(wx.EVT_RADIOBUTTON, self.OnSetRadio) self.Bind(grad.EVT_THRESHOLD_CHANGING, self.OnSlideChanged, self.threshold) + self.use_ww_wl.Bind(wx.EVT_CHECKBOX, self.OnSetUseWWWL) self.deviation_min.Bind(wx.EVT_SPINCTRL, self.OnSetDeviation) self.deviation_max.Bind(wx.EVT_SPINCTRL, self.OnSetDeviation) self.Bind(wx.EVT_CLOSE, self.OnClose) @@ -2186,6 +2192,9 @@ class FFillSegmentationOptionsDialog(wx.Dialog): self.config.t1 = int(self.threshold.GetMaxValue()) print self.config.t0, self.config.t1 + def OnSetUseWWWL(self, evt): + self.config.use_ww_wl = self.use_ww_wl.GetValue() + def OnSetDeviation(self, evt): self.config.dev_max = self.deviation_max.GetValue() self.config.dev_min = self.deviation_min.GetValue() -- libgit2 0.21.2