Commit 771e0d4fdb917b7321e6c9483fecb066ab8f2e36
1 parent
59848d20
Exists in
master
and in
68 other branches
ENH: Reading 8 bit raycasting presets really
Showing
3 changed files
with
18 additions
and
6 deletions
Show diff stats
invesalius/constants.py
1 | +import os.path | |
1 | 2 | from project import Project |
2 | 3 | |
3 | 4 | # Slice orientation |
... | ... | @@ -135,3 +136,5 @@ REDUCE_IMAGEDATA_QUALITY = 1 |
135 | 136 | |
136 | 137 | # if 1, use vtkVolumeRaycastMapper, if 0, use vtkFixedPointVolumeRayCastMapper |
137 | 138 | TYPE_RAYCASTING_MAPPER = 0 |
139 | + | |
140 | +RAYCASTING_PRESETS_DIRECTORY= os.path.join("..", "presets", "raycasting") | ... | ... |
invesalius/control.py
... | ... | @@ -7,7 +7,7 @@ import data.imagedata_utils as utils |
7 | 7 | import data.surface as surface |
8 | 8 | import data.volume as volume |
9 | 9 | import reader.dicom_reader as dicom |
10 | -import reader.analyze_reader as analyze | |
10 | +#import reader.analyze_reader as analyze | |
11 | 11 | |
12 | 12 | DEFAULT_THRESH_MODE = 0 |
13 | 13 | ... | ... |
invesalius/data/volume.py
... | ... | @@ -128,12 +128,10 @@ class Volume(): |
128 | 128 | ps.Publisher.sendMessage('Set colour interactor', colour) |
129 | 129 | |
130 | 130 | def __config_preset(self): |
131 | - print ">>Config" | |
132 | 131 | if self.config['advancedCLUT']: |
133 | 132 | self.Create16bColorTable(self.scale) |
134 | 133 | self.CreateOpacityTable(self.scale) |
135 | 134 | else: |
136 | - print ">>>here" | |
137 | 135 | self.Create8bColorTable(self.scale) |
138 | 136 | self.Create8bOpacityTable(self.scale) |
139 | 137 | |
... | ... | @@ -195,11 +193,17 @@ class Volume(): |
195 | 193 | self.color_transfer = color_transfer |
196 | 194 | |
197 | 195 | def Create8bColorTable(self, scale): |
198 | - color_transfer = vtk.vtkColorTransferFunction() | |
196 | + if self.color_transfer: | |
197 | + color_transfer = self.color_transfer | |
198 | + else: | |
199 | + color_transfer = vtk.vtkColorTransferFunction() | |
199 | 200 | color_transfer.RemoveAllPoints() |
200 | 201 | color_preset = self.config['CLUT'] |
202 | + print ">>>", color_preset | |
201 | 203 | if color_preset != "No CLUT": |
202 | - p = plistlib.readPlist(os.path.join('ColorList', color_preset + '.plist')) | |
204 | + p = plistlib.readPlist( | |
205 | + os.path.join(constants.RAYCASTING_PRESETS_DIRECTORY, | |
206 | + 'ColorList', color_preset + '.plist')) | |
203 | 207 | print "nome clut", p |
204 | 208 | r = p['Red'] |
205 | 209 | g = p['Green'] |
... | ... | @@ -211,6 +215,7 @@ class Volume(): |
211 | 215 | for i,rgb in enumerate(colors): |
212 | 216 | print i,inc, ww, wl - ww/2 + i * inc, rgb |
213 | 217 | color_transfer.AddRGBPoint((wl - ww/2) + (i * inc), *[i/255.0 for i in rgb]) |
218 | + self.color_transfer = color_transfer | |
214 | 219 | return color_transfer |
215 | 220 | |
216 | 221 | def CreateOpacityTable(self, scale): |
... | ... | @@ -248,7 +253,10 @@ class Volume(): |
248 | 253 | self.opacity_transfer_func = opacity_transfer_func |
249 | 254 | |
250 | 255 | def Create8bOpacityTable(self, scale): |
251 | - opacity_transfer_func = vtk.vtkPiecewiseFunction() | |
256 | + if self.opacity_transfer_func: | |
257 | + opacity_transfer_func = self.opacity_transfer_func | |
258 | + else: | |
259 | + opacity_transfer_func = vtk.vtkPiecewiseFunction() | |
252 | 260 | opacity_transfer_func.RemoveAllPoints() |
253 | 261 | opacities = [] |
254 | 262 | |
... | ... | @@ -271,6 +279,7 @@ class Volume(): |
271 | 279 | opacity_transfer_func.AddPoint(l1, 0) |
272 | 280 | opacity_transfer_func.AddPoint(l2, 1) |
273 | 281 | |
282 | + self.opacity_transfer_func = opacity_transfer_func | |
274 | 283 | return opacity_transfer_func |
275 | 284 | |
276 | 285 | def CreateBackgroundColor(self): | ... | ... |