[vtkusers] Volume Rendering - Using different scalars for opacity and color transfer function

paule paul.klemm at googlemail.com
Thu Sep 27 13:39:43 EDT 2012


Hello everyone,
 
I have a three dimensional volume (vtkImageData) which is rendered using ray
casting (vtkFixedPointVolumeRayCastMapper). I attached an opacity
(vtkPiecewiseFunction) and colour transfer function
(vtkColorTransferFunction) to it using vtkVolumeProperty.
 
The volume consists of two scalar attributes. I want to map the first scalar
attribute of a voxel to opacity and the second attribute of the same voxel
to the colour. I'm stuck on figuring out how to do that! At the moment, I
create two vtkVolume for rendering each scalar attribute itself. However,
the result is not satisfying.

Here is a minimal code example in python to describe the problem:

volume = scaledInput.GetOutput()
 
opacityTF = vtkPiecewiseFunction()
opacityTF.AddPoint(self.minimum, 0.0)
opacityTF.AddPoint(self.maximum, 0.1)
 
# At this point I want to use the scalars which stem from the magnitude
field of the vector field
colorTF = vtkColorTransferFunction()
colorTF.AddRGBPoint(self.minimum, 0, 1, 0)
colorTF.AddRGBPoint(self.maximum, 1, 0, 0)
 
volprop = vtkVolumeProperty()
volprop.SetColor(colorTF)
volprop.SetScalarOpacity(opacityTF)
 
compositeFunction = vtkVolumeRayCastCompositeFunction()
volumeMapper = vtkVolumeRayCastMapper()
volumeMapper.AutoAdjustSampleDistancesOn()
volumeMapper.SetVolumeRayCastFunction(compositeFunction)
volumeMapper.SetInput(volume)
 
volumeActor = vtkVolume()
volumeActor.SetMapper(volumeMapper)
volumeActor.SetProperty(volprop)
 
renderer =
self.ui.qvtkWidget.GetRenderWindow().GetRenderers().GetFirstRenderer()
renderer.AddVolume(volumeActor)
self.repaint()

Cheers,
Paul



--
View this message in context: http://vtk.1045678.n5.nabble.com/Volume-Rendering-Using-different-scalars-for-opacity-and-color-transfer-function-tp5716336.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list