[vtkusers] [try again]Volume Rendering with RGB values from PPM files
Naoko TAKAYA
takaya at cv.cs.ritsumei.ac.jp
Mon May 27 02:04:23 EDT 2002
Dear Vtkusers
I'm trying to reconstruct a 3D volume from PPM files, which
are slice images of human brain.
I want each resulting voxels to have RGB values from those
PPM files and render the volume using volume raycasting.
I understand that to do volume rendering you use;
vtkPiecewiseFunction - for opacity
vtkColorTransferFunction - for volume colors
vtkVolumeProperty - for setting volume propeties from the two
functions above
vtkVolumeRayCastCompositeFunction
vtkVolumeRayCastMapper
vtkVolume
How do you sepcify colors using vtkColorTransferFunction
from PPM files read ?
Is this possible using VTK?
If so please tell me how to do it.
I'm using VTK4.0 and Microsoft Visual C++ 6.0.
The brief code is followed.
Any advice is appreciated ;)
Thank you in advance.
Naoko Takaya
takaya at cv.cs.ritsumei.ac.jp
vtkPNMReader *vPPM = vtkPNMReader::New();
vPPM -> SetDataByteOrderToLittleEndian();
vPPM -> SetFilePrefix("filename.ppm");
vPPM -> SetFilePattern("filename.ppm.%d");
vPPM -> SetDataExtent(0,167,0,190,000,100);
vPPM -> SetDataSpacing(1,1,1);
vPPM -> SetDataScalarTypeToUnsignedShort();
vPPM -> Update();
vtkPiecewiseFunction *vOTFun = vtkPiecewiseFunction::New();
vOTFun -> AddSegment(0,0,255,1);
vtkVolumeProperty *vVolProp = vtkVolumeProperty::New();
vtkColorTransferFunction *vClrFun = vtkColorTransferFunction::New();
vClrFun -> ????????
vVolProp -> SetColor(vClrFun);
vVolProp -> SetScalarOpacity(vOTFun);
vVolProp -> SetInterpolationTypeToLinear();
vVolProp -> ShadeOn();
vtkVolumeRayCastCompositeFunction *vCFunction = vtkVolumeRayCastCompositeFunction::New();
vtkVolumeRayCastMapper *vVolMapper =vtkVolumeRayCastMapper::New();
vVolMapper -> SetInput(vPPM->GetOutput());
vVolMapper -> SetVolumeRayCastFunction(vCFunction);
vVolMapper -> SetSampleDistance(1);
vtkVolume *vVolActor = vtkVolume::New();
vVolActor -> SetMapper(vVolMapper);
vVolActor -> SetProperty(vVolProp);
vRenderer -> AddProp(vVolActor);
More information about the vtkusers
mailing list