[vtkusers] about volume rendering on color images

Yixun Liu yxliu at fudan.edu.cn
Tue Aug 1 10:18:26 EDT 2006


Hi,

I have 256x256x200 color tiff image. I want to render it using raycasting. I did it as below,

Firstly, compute 4th component (averageIntensity) based on the R,G and B components.
averageIntensity = R*0.30 + G*0.59 + B]*0.11;

Then generate a vtkImageData (finalImg), which includes 4 components: R, G, B and  averageIntensity. The first three will directly represent RGB (no lookup table). The fourth component will be passed through the first scalar opacity transfer function for opacity.


//mapper
 vtkVolumeRayCastCompositeFunction *compositeFunction = vtkVolumeRayCastCompositeFunction::New();
 vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();
 volumeMapper->SetInput(finalImg);
 volumeMapper->SetVolumeRayCastFunction(compositeFunction);
 volumeMapper->IndependentComponentsOff();

//opacity intepolation function
 vtkPiecewiseFunction *tfun = vtkPiecewiseFunction::New();
 tfun->AddPoint(0.0, 0.0);
 tfun->AddPoint(128.0, 0.1);
 tfun->AddPoint(255.0, 0.0);

//property
 vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
 volumeProperty->SetScalarOpacity(3, tfun);


//volume
 vtkVolume *newvol = vtkVolume::New();
 newvol->SetMapper(volumeMapper);
 newvol->SetProperty(volumeProperty);

However, I cannot get a color volume.

Hope your help!

Regards,

Yixun Liu





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060801/9f7c08c3/attachment.htm>


More information about the vtkusers mailing list