Commit 46b08a73e91ed891342dd8e349504723db497ae8

Authored by Paulo Henrique Junqueira Amorim
1 parent 1dfad6a7

ADD: Automatic calculation of window and level initial

Showing 1 changed file with 7 additions and 4 deletions   Show diff stats
invesalius/control.py
... ... @@ -93,13 +93,16 @@ class Controller():
93 93 proj.SetAcquisitionModality(acquisition_modality)
94 94 proj.imagedata = imagedata
95 95 proj.original_orientation = orientation
96   - proj.window = window
97   - proj.level = level
  96 +
  97 +
  98 + threshold_range = proj.imagedata.GetScalarRange()
  99 +
  100 + proj.window = window = threshold_range[1] - threshold_range[0]
  101 + proj.level = level = (0.5 * (threshold_range[1] + threshold_range[0]))
98 102  
99 103 const.WINDOW_LEVEL['Default'] = (window, level)
100 104 const.WINDOW_LEVEL['Other'] = (window, level)
101   -
102   - threshold_range = proj.imagedata.GetScalarRange()
  105 +
103 106 const.THRESHOLD_OUTVALUE = threshold_range[0]
104 107 const.THRESHOLD_INVALUE = threshold_range[1]
105 108  
... ...