Commit 0bc27bcb98f3788d2742e4a38f8317d76ffcb276
1 parent
ddfad4f1
Exists in
master
and in
6 other branches
FIX: Better MIP Support, added a MIP preset
Showing
4 changed files
with
134 additions
and
30 deletions
Show diff stats
.gitattributes
... | ... | @@ -157,6 +157,7 @@ presets/raycasting/Glossy.plist -text |
157 | 157 | presets/raycasting/Gold[!!-~]Bone.plist -text |
158 | 158 | presets/raycasting/High[!!-~]Contrast.plist -text |
159 | 159 | presets/raycasting/Low[!!-~]Contrast.plist -text |
160 | +presets/raycasting/MIP.plist -text | |
160 | 161 | presets/raycasting/Mid[!!-~]Contrast.plist -text |
161 | 162 | presets/raycasting/No[!!-~]Shading.plist -text |
162 | 163 | presets/raycasting/Pencil.plist -text | ... | ... |
invesalius/constants.py
... | ... | @@ -225,7 +225,7 @@ WINDOW_LEVEL = {"Abdomen":(350,50), |
225 | 225 | "Vasculature - Hard":(240,80), |
226 | 226 | "Vasculature - Soft":(650,160)} |
227 | 227 | |
228 | -REDUCE_IMAGEDATA_QUALITY = 1 | |
228 | +REDUCE_IMAGEDATA_QUALITY = 0 | |
229 | 229 | |
230 | 230 | |
231 | 231 | ICON_DIR = os.path.abspath(os.path.join('..', 'icons')) |
... | ... | @@ -239,7 +239,7 @@ ID_TO_BMP = {VOL_FRONT: ["Front", os.path.join(ICON_DIR, "view_front.png")], |
239 | 239 | } |
240 | 240 | |
241 | 241 | # if 1, use vtkVolumeRaycastMapper, if 0, use vtkFixedPointVolumeRayCastMapper |
242 | -TYPE_RAYCASTING_MAPPER = 1 | |
242 | +TYPE_RAYCASTING_MAPPER = 0 | |
243 | 243 | |
244 | 244 | folder=RAYCASTING_PRESETS_DIRECTORY= os.path.abspath(os.path.join("..", |
245 | 245 | "presets", | ... | ... |
invesalius/data/volume.py
... | ... | @@ -70,7 +70,7 @@ SHADING = { |
70 | 70 | |
71 | 71 | |
72 | 72 | class Volume(): |
73 | - | |
73 | + | |
74 | 74 | def __init__(self): |
75 | 75 | self.config = None |
76 | 76 | self.exist = None |
... | ... | @@ -81,9 +81,9 @@ class Volume(): |
81 | 81 | self.curve = 0 |
82 | 82 | self.plane = None |
83 | 83 | self.plane_on = False |
84 | - | |
84 | + | |
85 | 85 | self.__bind_events() |
86 | - | |
86 | + | |
87 | 87 | def __bind_events(self): |
88 | 88 | ps.Publisher().subscribe(self.OnHideVolume, |
89 | 89 | 'Hide raycasting volume') |
... | ... | @@ -387,12 +387,22 @@ class Volume(): |
387 | 387 | self.volume_properties.SetSpecularPower(shading['specularPower']) |
388 | 388 | |
389 | 389 | def SetTypeRaycasting(self): |
390 | - if self.config['name'].upper().startswith('MIP'): | |
391 | - print "MIP" | |
392 | - self.volume_mapper.SetBlendModeToMaximumIntensity() | |
390 | + if self.volume_mapper.IsA("vtkFixedPointVolumeRayCastMapper"): | |
391 | + if self.config.get('MIP', False): | |
392 | + print "MIP" | |
393 | + self.volume_mapper.SetBlendModeToMaximumIntensity() | |
394 | + else: | |
395 | + print "Composite" | |
396 | + self.volume_mapper.SetBlendModeToComposite() | |
393 | 397 | else: |
394 | - print "Composite" | |
395 | - self.volume_mapper.SetBlendModeToComposite() | |
398 | + if self.config.get('MIP', False): | |
399 | + print "MIP" | |
400 | + raycasting_function = vtk.vtkVolumeRayCastMIPFunction() | |
401 | + else: | |
402 | + print "Composite" | |
403 | + raycasting_function = vtk.vtkVolumeRayCastCompositeFunction() | |
404 | + raycasting_function.SetCompositeMethodToInterpolateFirst() | |
405 | + self.volume_mapper.SetVolumeRayCastFunction(raycasting_function) | |
396 | 406 | |
397 | 407 | def ApplyConvolution(self, imagedata, update_progress = None): |
398 | 408 | number_filters = len(self.config['convolutionFilters']) |
... | ... | @@ -412,7 +422,7 @@ class Volume(): |
412 | 422 | def LoadVolume(self): |
413 | 423 | proj = prj.Project() |
414 | 424 | image = proj.imagedata |
415 | - | |
425 | + | |
416 | 426 | number_filters = len(self.config['convolutionFilters']) |
417 | 427 | update_progress= vtk_utils.ShowProgress(2 + number_filters) |
418 | 428 | |
... | ... | @@ -424,7 +434,7 @@ class Volume(): |
424 | 434 | flip.AddObserver("ProgressEvent", lambda obj,evt: |
425 | 435 | update_progress(flip, "Rendering...")) |
426 | 436 | flip.Update() |
427 | - | |
437 | + | |
428 | 438 | image = flip.GetOutput() |
429 | 439 | |
430 | 440 | scale = image.GetScalarRange() |
... | ... | @@ -445,17 +455,10 @@ class Volume(): |
445 | 455 | else: |
446 | 456 | self.Create8bColorTable(scale) |
447 | 457 | self.Create8bOpacityTable(scale) |
448 | - | |
449 | - | |
458 | + | |
450 | 459 | image2 = self.ApplyConvolution(image2.GetOutput(), update_progress) |
451 | 460 | self.final_imagedata = image2 |
452 | 461 | |
453 | - composite_function = vtk.vtkVolumeRayCastCompositeFunction() | |
454 | - composite_function.SetCompositeMethodToInterpolateFirst() | |
455 | - | |
456 | - gradientEstimator = vtk.vtkFiniteDifferenceGradientEstimator() | |
457 | - gradientEstimator.SetGradientMagnitudeScale(1) | |
458 | - | |
459 | 462 | # Changed the vtkVolumeRayCast to vtkFixedPointVolumeRayCastMapper |
460 | 463 | # because it's faster and the image is better |
461 | 464 | # TODO: To test if it's true. |
... | ... | @@ -463,7 +466,7 @@ class Volume(): |
463 | 466 | volume_mapper = vtk.vtkVolumeRayCastMapper() |
464 | 467 | #volume_mapper.AutoAdjustSampleDistancesOff() |
465 | 468 | #volume_mapper.SetInput(image2) |
466 | - volume_mapper.SetVolumeRayCastFunction(composite_function) | |
469 | + #volume_mapper.SetVolumeRayCastFunction(composite_function) | |
467 | 470 | #volume_mapper.SetGradientEstimator(gradientEstimator) |
468 | 471 | volume_mapper.IntermixIntersectingGeometryOn() |
469 | 472 | self.volume_mapper = volume_mapper |
... | ... | @@ -471,9 +474,9 @@ class Volume(): |
471 | 474 | volume_mapper = vtk.vtkFixedPointVolumeRayCastMapper() |
472 | 475 | #volume_mapper.AutoAdjustSampleDistancesOff() |
473 | 476 | self.volume_mapper = volume_mapper |
474 | - self.SetTypeRaycasting() | |
475 | 477 | volume_mapper.IntermixIntersectingGeometryOn() |
476 | 478 | |
479 | + self.SetTypeRaycasting() | |
477 | 480 | volume_mapper.SetInput(image2) |
478 | 481 | |
479 | 482 | # TODO: Look to this |
... | ... | @@ -487,11 +490,6 @@ class Volume(): |
487 | 490 | |
488 | 491 | volume_properties = vtk.vtkVolumeProperty() |
489 | 492 | #volume_properties.IndependentComponentsOn() |
490 | - if self.config['useShading']: | |
491 | - volume_properties.ShadeOn() | |
492 | - else: | |
493 | - volume_properties.ShadeOff() | |
494 | - | |
495 | 493 | volume_properties.SetInterpolationTypeToLinear() |
496 | 494 | volume_properties.SetColor(self.color_transfer) |
497 | 495 | |
... | ... | @@ -508,20 +506,21 @@ class Volume(): |
508 | 506 | volume_mapper.SetImageSampleDistance(0.25) |
509 | 507 | volume_mapper.SetSampleDistance(pix_diag / 5.0) |
510 | 508 | volume_properties.SetScalarOpacityUnitDistance(pix_diag) |
511 | - | |
509 | + | |
512 | 510 | self.volume_properties = volume_properties |
513 | 511 | |
512 | + self.SetShading() | |
513 | + | |
514 | 514 | volume = vtk.vtkVolume() |
515 | 515 | volume.SetMapper(volume_mapper) |
516 | 516 | volume.SetProperty(volume_properties) |
517 | 517 | self.volume = volume |
518 | - | |
518 | + | |
519 | 519 | colour = self.GetBackgroundColour() |
520 | 520 | |
521 | 521 | ps.Publisher().sendMessage('Load volume into viewer', |
522 | 522 | (volume, colour, (self.ww, self.wl))) |
523 | 523 | |
524 | - | |
525 | 524 | def OnEnableTool(self, pubsub_evt): |
526 | 525 | print "OnEnableTool" |
527 | 526 | tool_name, enable = pubsub_evt.data | ... | ... |
... | ... | @@ -0,0 +1,104 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
3 | +<plist version="1.0"> | |
4 | +<dict> | |
5 | + <key>16bitClutColors</key> | |
6 | + <array> | |
7 | + <array> | |
8 | + <dict> | |
9 | + <key>blue</key> | |
10 | + <real>0.0</real> | |
11 | + <key>green</key> | |
12 | + <real>0.0</real> | |
13 | + <key>red</key> | |
14 | + <real>0.0</real> | |
15 | + </dict> | |
16 | + <dict> | |
17 | + <key>blue</key> | |
18 | + <real>1.0</real> | |
19 | + <key>green</key> | |
20 | + <real>1.0</real> | |
21 | + <key>red</key> | |
22 | + <real>1.0</real> | |
23 | + </dict> | |
24 | + <dict> | |
25 | + <key>blue</key> | |
26 | + <real>1.0</real> | |
27 | + <key>green</key> | |
28 | + <real>1.0</real> | |
29 | + <key>red</key> | |
30 | + <real>1.0</real> | |
31 | + </dict> | |
32 | + <dict> | |
33 | + <key>blue</key> | |
34 | + <real>1.0</real> | |
35 | + <key>green</key> | |
36 | + <real>1.0</real> | |
37 | + <key>red</key> | |
38 | + <real>1.0</real> | |
39 | + </dict> | |
40 | + </array> | |
41 | + </array> | |
42 | + <key>16bitClutCurves</key> | |
43 | + <array> | |
44 | + <array> | |
45 | + <dict> | |
46 | + <key>x</key> | |
47 | + <real>-1024.0</real> | |
48 | + <key>y</key> | |
49 | + <real>0.0</real> | |
50 | + </dict> | |
51 | + <dict> | |
52 | + <key>x</key> | |
53 | + <real>596.66286215978903</real> | |
54 | + <key>y</key> | |
55 | + <real>0.25342465753424659</real> | |
56 | + </dict> | |
57 | + <dict> | |
58 | + <key>x</key> | |
59 | + <real>2541.4582967515362</real> | |
60 | + <key>y</key> | |
61 | + <real>1.0</real> | |
62 | + </dict> | |
63 | + <dict> | |
64 | + <key>x</key> | |
65 | + <real>3032.9999999999995</real> | |
66 | + <key>y</key> | |
67 | + <real>1.0</real> | |
68 | + </dict> | |
69 | + </array> | |
70 | + </array> | |
71 | + <key>CLUT</key> | |
72 | + <string>16-bit CLUT</string> | |
73 | + <key>advancedCLUT</key> | |
74 | + <true/> | |
75 | + <key>backgroundColorBlueComponent</key> | |
76 | + <real>0.0</real> | |
77 | + <key>backgroundColorGreenComponent</key> | |
78 | + <real>0.0</real> | |
79 | + <key>backgroundColorRedComponent</key> | |
80 | + <real>0.0</real> | |
81 | + <key>convolutionFilters</key> | |
82 | + <array> | |
83 | + <string>Basic Smooth 5x5</string> | |
84 | + </array> | |
85 | + <key>groupName</key> | |
86 | + <string>Soft Tissue CT</string> | |
87 | + <key>name</key> | |
88 | + <string>MIP</string> | |
89 | + <key>opacity</key> | |
90 | + <string>Logarithmic Inverse Table</string> | |
91 | + <key>projection</key> | |
92 | + <integer>1</integer> | |
93 | + <key>shading</key> | |
94 | + <string>Endoscopy</string> | |
95 | + <key>useShading</key> | |
96 | + <true/> | |
97 | + <key>MIP</key> | |
98 | + <true/> | |
99 | + <key>wl</key> | |
100 | + <real>-439.46817016601562</real> | |
101 | + <key>ww</key> | |
102 | + <real>408.62579345703125</real> | |
103 | +</dict> | |
104 | +</plist> | ... | ... |