Commit 59848d2087b4819548a3b4f78505f4ed1b20a8fd
1 parent
1a050b55
Exists in
master
and in
68 other branches
ENH: improving reading 8 bit preset raycasting
Showing
1 changed file
with
12 additions
and
9 deletions
Show diff stats
invesalius/data/volume.py
@@ -123,19 +123,19 @@ class Volume(): | @@ -123,19 +123,19 @@ class Volume(): | ||
123 | def SetRaycastPreset(self, pubsub_evt): | 123 | def SetRaycastPreset(self, pubsub_evt): |
124 | self.LoadConfig(pubsub_evt.data) | 124 | self.LoadConfig(pubsub_evt.data) |
125 | self.__config_preset() | 125 | self.__config_preset() |
126 | - self.Create16bColorTable(self.scale) | ||
127 | - self.CreateOpacityTable(self.scale) | ||
128 | self.SetShading() | 126 | self.SetShading() |
129 | colour = self.CreateBackgroundColor() | 127 | colour = self.CreateBackgroundColor() |
130 | ps.Publisher.sendMessage('Set colour interactor', colour) | 128 | ps.Publisher.sendMessage('Set colour interactor', colour) |
131 | 129 | ||
132 | def __config_preset(self): | 130 | def __config_preset(self): |
131 | + print ">>Config" | ||
133 | if self.config['advancedCLUT']: | 132 | if self.config['advancedCLUT']: |
134 | self.Create16bColorTable(self.scale) | 133 | self.Create16bColorTable(self.scale) |
135 | self.CreateOpacityTable(self.scale) | 134 | self.CreateOpacityTable(self.scale) |
136 | else: | 135 | else: |
137 | - self.Create8bColorTable() | ||
138 | - self.Create8bOpacityTable() | 136 | + print ">>>here" |
137 | + self.Create8bColorTable(self.scale) | ||
138 | + self.Create8bOpacityTable(self.scale) | ||
139 | 139 | ||
140 | def SetWWWL(self, pubsub_evt): | 140 | def SetWWWL(self, pubsub_evt): |
141 | ww, wl, n = pubsub_evt.data | 141 | ww, wl, n = pubsub_evt.data |
@@ -194,11 +194,13 @@ class Volume(): | @@ -194,11 +194,13 @@ class Volume(): | ||
194 | r, g, b) | 194 | r, g, b) |
195 | self.color_transfer = color_transfer | 195 | self.color_transfer = color_transfer |
196 | 196 | ||
197 | - def Create8bColorTable(self): | 197 | + def Create8bColorTable(self, scale): |
198 | color_transfer = vtk.vtkColorTransferFunction() | 198 | color_transfer = vtk.vtkColorTransferFunction() |
199 | + color_transfer.RemoveAllPoints() | ||
199 | color_preset = self.config['CLUT'] | 200 | color_preset = self.config['CLUT'] |
200 | if color_preset != "No CLUT": | 201 | if color_preset != "No CLUT": |
201 | - p = plistlib.readPlist( os.path.join('ColorList', color_preset + '.plist')) | 202 | + p = plistlib.readPlist(os.path.join('ColorList', color_preset + '.plist')) |
203 | + print "nome clut", p | ||
202 | r = p['Red'] | 204 | r = p['Red'] |
203 | g = p['Green'] | 205 | g = p['Green'] |
204 | b = p['Blue'] | 206 | b = p['Blue'] |
@@ -245,8 +247,9 @@ class Volume(): | @@ -245,8 +247,9 @@ class Volume(): | ||
245 | self.TranslateScale(scale, gray_level), opacity) | 247 | self.TranslateScale(scale, gray_level), opacity) |
246 | self.opacity_transfer_func = opacity_transfer_func | 248 | self.opacity_transfer_func = opacity_transfer_func |
247 | 249 | ||
248 | - def Create8bOpacityTable(self): | 250 | + def Create8bOpacityTable(self, scale): |
249 | opacity_transfer_func = vtk.vtkPiecewiseFunction() | 251 | opacity_transfer_func = vtk.vtkPiecewiseFunction() |
252 | + opacity_transfer_func.RemoveAllPoints() | ||
250 | opacities = [] | 253 | opacities = [] |
251 | 254 | ||
252 | ww = self.config['ww'] | 255 | ww = self.config['ww'] |
@@ -346,8 +349,8 @@ class Volume(): | @@ -346,8 +349,8 @@ class Volume(): | ||
346 | cast.SetShift(abs(scale[0])) | 349 | cast.SetShift(abs(scale[0])) |
347 | #cast.SetScale(255.0/(scale[1] - scale[0])) | 350 | #cast.SetScale(255.0/(scale[1] - scale[0])) |
348 | cast.SetOutputScalarTypeToUnsignedShort() | 351 | cast.SetOutputScalarTypeToUnsignedShort() |
349 | - color_transfer = self.Create8bColorTable() | ||
350 | - opacity_transfer_func = self.Create8bOpacityTable() | 352 | + color_transfer = self.Create8bColorTable(scale) |
353 | + opacity_transfer_func = self.Create8bOpacityTable(scale) | ||
351 | cast.Update() | 354 | cast.Update() |
352 | image2 = cast | 355 | image2 = cast |
353 | #cast.ClampOverflowOff() | 356 | #cast.ClampOverflowOff() |