Permalink
Browse files

FIX: Better MIP Support, added a MIP preset

git-svn-id: http://svn.softwarepublico.gov.br/svn/invesalius/invesalius3/trunk@1212 e1d098d0-f32f-0410-9823-cb12c6f6c872
  • Loading branch information...
1 parent 3bfd67a commit eda4d62be0e692fcc06323ab23df39e601f627a5 totonixsame@gmail.com committed Dec 9, 2009
Showing with 133 additions and 30 deletions.
  1. +2 −2 invesalius/constants.py
  2. +27 −28 invesalius/data/volume.py
  3. +104 −0 presets/raycasting/MIP.plist
View
@@ -225,7 +225,7 @@
"Vasculature - Hard":(240,80),
"Vasculature - Soft":(650,160)}
-REDUCE_IMAGEDATA_QUALITY = 1
+REDUCE_IMAGEDATA_QUALITY = 0
ICON_DIR = os.path.abspath(os.path.join('..', 'icons'))
@@ -239,7 +239,7 @@
}
# if 1, use vtkVolumeRaycastMapper, if 0, use vtkFixedPointVolumeRayCastMapper
-TYPE_RAYCASTING_MAPPER = 1
+TYPE_RAYCASTING_MAPPER = 0
folder=RAYCASTING_PRESETS_DIRECTORY= os.path.abspath(os.path.join("..",
"presets",
View
@@ -70,7 +70,7 @@
class Volume():
-
+
def __init__(self):
self.config = None
self.exist = None
@@ -81,9 +81,9 @@ def __init__(self):
self.curve = 0
self.plane = None
self.plane_on = False
-
+
self.__bind_events()
-
+
def __bind_events(self):
ps.Publisher().subscribe(self.OnHideVolume,
'Hide raycasting volume')
@@ -387,12 +387,22 @@ def SetShading(self):
self.volume_properties.SetSpecularPower(shading['specularPower'])
def SetTypeRaycasting(self):
- if self.config['name'].upper().startswith('MIP'):
- print "MIP"
- self.volume_mapper.SetBlendModeToMaximumIntensity()
+ if self.volume_mapper.IsA("vtkFixedPointVolumeRayCastMapper"):
+ if self.config.get('MIP', False):
+ print "MIP"
+ self.volume_mapper.SetBlendModeToMaximumIntensity()
+ else:
+ print "Composite"
+ self.volume_mapper.SetBlendModeToComposite()
else:
- print "Composite"
- self.volume_mapper.SetBlendModeToComposite()
+ if self.config.get('MIP', False):
+ print "MIP"
+ raycasting_function = vtk.vtkVolumeRayCastMIPFunction()
+ else:
+ print "Composite"
+ raycasting_function = vtk.vtkVolumeRayCastCompositeFunction()
+ raycasting_function.SetCompositeMethodToInterpolateFirst()
+ self.volume_mapper.SetVolumeRayCastFunction(raycasting_function)
def ApplyConvolution(self, imagedata, update_progress = None):
number_filters = len(self.config['convolutionFilters'])
@@ -412,7 +422,7 @@ def ApplyConvolution(self, imagedata, update_progress = None):
def LoadVolume(self):
proj = prj.Project()
image = proj.imagedata
-
+
number_filters = len(self.config['convolutionFilters'])
update_progress= vtk_utils.ShowProgress(2 + number_filters)
@@ -424,7 +434,7 @@ def LoadVolume(self):
flip.AddObserver("ProgressEvent", lambda obj,evt:
update_progress(flip, "Rendering..."))
flip.Update()
-
+
image = flip.GetOutput()
scale = image.GetScalarRange()
@@ -445,35 +455,28 @@ def LoadVolume(self):
else:
self.Create8bColorTable(scale)
self.Create8bOpacityTable(scale)
-
-
+
image2 = self.ApplyConvolution(image2.GetOutput(), update_progress)
self.final_imagedata = image2
- composite_function = vtk.vtkVolumeRayCastCompositeFunction()
- composite_function.SetCompositeMethodToInterpolateFirst()
-
- gradientEstimator = vtk.vtkFiniteDifferenceGradientEstimator()
- gradientEstimator.SetGradientMagnitudeScale(1)
-
# Changed the vtkVolumeRayCast to vtkFixedPointVolumeRayCastMapper
# because it's faster and the image is better
# TODO: To test if it's true.
if const.TYPE_RAYCASTING_MAPPER:
volume_mapper = vtk.vtkVolumeRayCastMapper()
#volume_mapper.AutoAdjustSampleDistancesOff()
#volume_mapper.SetInput(image2)
- volume_mapper.SetVolumeRayCastFunction(composite_function)
+ #volume_mapper.SetVolumeRayCastFunction(composite_function)
#volume_mapper.SetGradientEstimator(gradientEstimator)
volume_mapper.IntermixIntersectingGeometryOn()
self.volume_mapper = volume_mapper
else:
volume_mapper = vtk.vtkFixedPointVolumeRayCastMapper()
#volume_mapper.AutoAdjustSampleDistancesOff()
self.volume_mapper = volume_mapper
- self.SetTypeRaycasting()
volume_mapper.IntermixIntersectingGeometryOn()
+ self.SetTypeRaycasting()
volume_mapper.SetInput(image2)
# TODO: Look to this
@@ -487,11 +490,6 @@ def LoadVolume(self):
volume_properties = vtk.vtkVolumeProperty()
#volume_properties.IndependentComponentsOn()
- if self.config['useShading']:
- volume_properties.ShadeOn()
- else:
- volume_properties.ShadeOff()
-
volume_properties.SetInterpolationTypeToLinear()
volume_properties.SetColor(self.color_transfer)
@@ -508,20 +506,21 @@ def LoadVolume(self):
volume_mapper.SetImageSampleDistance(0.25)
volume_mapper.SetSampleDistance(pix_diag / 5.0)
volume_properties.SetScalarOpacityUnitDistance(pix_diag)
-
+
self.volume_properties = volume_properties
+ self.SetShading()
+
volume = vtk.vtkVolume()
volume.SetMapper(volume_mapper)
volume.SetProperty(volume_properties)
self.volume = volume
-
+
colour = self.GetBackgroundColour()
ps.Publisher().sendMessage('Load volume into viewer',
(volume, colour, (self.ww, self.wl)))
-
def OnEnableTool(self, pubsub_evt):
print "OnEnableTool"
tool_name, enable = pubsub_evt.data
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>16bitClutColors</key>
+ <array>
+ <array>
+ <dict>
+ <key>blue</key>
+ <real>0.0</real>
+ <key>green</key>
+ <real>0.0</real>
+ <key>red</key>
+ <real>0.0</real>
+ </dict>
+ <dict>
+ <key>blue</key>
+ <real>1.0</real>
+ <key>green</key>
+ <real>1.0</real>
+ <key>red</key>
+ <real>1.0</real>
+ </dict>
+ <dict>
+ <key>blue</key>
+ <real>1.0</real>
+ <key>green</key>
+ <real>1.0</real>
+ <key>red</key>
+ <real>1.0</real>
+ </dict>
+ <dict>
+ <key>blue</key>
+ <real>1.0</real>
+ <key>green</key>
+ <real>1.0</real>
+ <key>red</key>
+ <real>1.0</real>
+ </dict>
+ </array>
+ </array>
+ <key>16bitClutCurves</key>
+ <array>
+ <array>
+ <dict>
+ <key>x</key>
+ <real>-1024.0</real>
+ <key>y</key>
+ <real>0.0</real>
+ </dict>
+ <dict>
+ <key>x</key>
+ <real>596.66286215978903</real>
+ <key>y</key>
+ <real>0.25342465753424659</real>
+ </dict>
+ <dict>
+ <key>x</key>
+ <real>2541.4582967515362</real>
+ <key>y</key>
+ <real>1.0</real>
+ </dict>
+ <dict>
+ <key>x</key>
+ <real>3032.9999999999995</real>
+ <key>y</key>
+ <real>1.0</real>
+ </dict>
+ </array>
+ </array>
+ <key>CLUT</key>
+ <string>16-bit CLUT</string>
+ <key>advancedCLUT</key>
+ <true/>
+ <key>backgroundColorBlueComponent</key>
+ <real>0.0</real>
+ <key>backgroundColorGreenComponent</key>
+ <real>0.0</real>
+ <key>backgroundColorRedComponent</key>
+ <real>0.0</real>
+ <key>convolutionFilters</key>
+ <array>
+ <string>Basic Smooth 5x5</string>
+ </array>
+ <key>groupName</key>
+ <string>Soft Tissue CT</string>
+ <key>name</key>
+ <string>MIP</string>
+ <key>opacity</key>
+ <string>Logarithmic Inverse Table</string>
+ <key>projection</key>
+ <integer>1</integer>
+ <key>shading</key>
+ <string>Endoscopy</string>
+ <key>useShading</key>
+ <true/>
+ <key>MIP</key>
+ <true/>
+ <key>wl</key>
+ <real>-439.46817016601562</real>
+ <key>ww</key>
+ <real>408.62579345703125</real>
+</dict>
+</plist>

0 comments on commit eda4d62

Please sign in to comment.