[vtkusers] [try again]Volume Rendering with RGB values from PPM files

Lisa S. Avila lisa.avila at kitware.com
Mon May 27 21:30:15 EDT 2002


Hello Naoko,

It is not currently possible to render anything other than single component 
unsigned char or unsigned short data with VTK.

Lisa


At 03:04 PM 5/27/2002 +0900, Naoko TAKAYA wrote:
>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);
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: 
><http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers





More information about the vtkusers mailing list