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 | 123 | def SetRaycastPreset(self, pubsub_evt): |
124 | 124 | self.LoadConfig(pubsub_evt.data) |
125 | 125 | self.__config_preset() |
126 | - self.Create16bColorTable(self.scale) | |
127 | - self.CreateOpacityTable(self.scale) | |
128 | 126 | self.SetShading() |
129 | 127 | colour = self.CreateBackgroundColor() |
130 | 128 | ps.Publisher.sendMessage('Set colour interactor', colour) |
131 | 129 | |
132 | 130 | def __config_preset(self): |
131 | + print ">>Config" | |
133 | 132 | if self.config['advancedCLUT']: |
134 | 133 | self.Create16bColorTable(self.scale) |
135 | 134 | self.CreateOpacityTable(self.scale) |
136 | 135 | else: |
137 | - self.Create8bColorTable() | |
138 | - self.Create8bOpacityTable() | |
136 | + print ">>>here" | |
137 | + self.Create8bColorTable(self.scale) | |
138 | + self.Create8bOpacityTable(self.scale) | |
139 | 139 | |
140 | 140 | def SetWWWL(self, pubsub_evt): |
141 | 141 | ww, wl, n = pubsub_evt.data |
... | ... | @@ -194,11 +194,13 @@ class Volume(): |
194 | 194 | r, g, b) |
195 | 195 | self.color_transfer = color_transfer |
196 | 196 | |
197 | - def Create8bColorTable(self): | |
197 | + def Create8bColorTable(self, scale): | |
198 | 198 | color_transfer = vtk.vtkColorTransferFunction() |
199 | + color_transfer.RemoveAllPoints() | |
199 | 200 | color_preset = self.config['CLUT'] |
200 | 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 | 204 | r = p['Red'] |
203 | 205 | g = p['Green'] |
204 | 206 | b = p['Blue'] |
... | ... | @@ -245,8 +247,9 @@ class Volume(): |
245 | 247 | self.TranslateScale(scale, gray_level), opacity) |
246 | 248 | self.opacity_transfer_func = opacity_transfer_func |
247 | 249 | |
248 | - def Create8bOpacityTable(self): | |
250 | + def Create8bOpacityTable(self, scale): | |
249 | 251 | opacity_transfer_func = vtk.vtkPiecewiseFunction() |
252 | + opacity_transfer_func.RemoveAllPoints() | |
250 | 253 | opacities = [] |
251 | 254 | |
252 | 255 | ww = self.config['ww'] |
... | ... | @@ -346,8 +349,8 @@ class Volume(): |
346 | 349 | cast.SetShift(abs(scale[0])) |
347 | 350 | #cast.SetScale(255.0/(scale[1] - scale[0])) |
348 | 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 | 354 | cast.Update() |
352 | 355 | image2 = cast |
353 | 356 | #cast.ClampOverflowOff() | ... | ... |