[vtkusers] Volume Rendering with Voxel Specific Color

Cory Jones cjayjones at gmail.com
Wed Jun 25 13:49:00 EDT 2014


I am trying to render a volume from 3D ImageData and I want to be able to
control the color of each voxel independently using the color channels. I
am able to set the number of scalar components in my ImageData to 3 and set
each channel separately. I am rendering using vtkSmartVolumeMapper. Is
there a way to set the vtkVolumeProperty so that the image renders the 3
channels as RGB? I have tried using the vtkColorTransferFunction
SetColorSpaceToRGB(), but this does not work. Again, I don't want to do
scalar color mapping. My current code is:


  vtkSmartPointer<vtkSmartVolumeMapper> volumeMapper =
              vtkSmartPointer<vtkSmartVolumeMapper>::New();
  volumeMapper->SetBlendModeToComposite();
  volumeMapper->SetInputConnection(outputImageData->GetProducerPort());

  vtkSmartPointer<vtkVolumeProperty> volumeProperty =
    vtkSmartPointer<vtkVolumeProperty>::New();
  volumeProperty->ShadeOff();
  volumeProperty->SetInterpolationType(VTK_LINEAR_INTERPOLATION);

  vtkSmartPointer<vtkColorTransferFunction> color =
    vtkSmartPointer<vtkColorTransferFunction>::New();
  color->SetColorSpaceToRGB();
  volumeProperty->SetColor(color);

  vtkSmartPointer<vtkVolume> volume =
    vtkSmartPointer<vtkVolume>::New();
  volume->SetMapper(volumeMapper);
  volume->SetProperty(volumeProperty);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140625/6947e790/attachment.html>


More information about the vtkusers mailing list