Display 3D image in RGB

Dear All,

I want to display a 3D image in RGB. What is missing in the following code?

    self.image_3d = vtk.vtkImageData()
    self.image_3d.SetDimensions(dim5)
    self.image_3d.SetSpacing(scale5)
    points = self.image_3d.GetPointData()
    points.SetScalars(numpy_support.numpy_to_vtk(
        np.zeros((dim5[0]*dim5[1]*dim5[2],3), dtype=np.uint8)))
    #Fill image with data
    self.volumeMapper_3d = vtk.vtkOpenGLGPUVolumeRayCastMapper()
    self.volumeMapper_3d.SetInputData(self.image_3d)
    self.volume_3d = vtk.vtkVolume()
    self.volume_3d.PickableOff()
    self.volume_3d.SetMapper(self.volumeMapper_3d)
    self.volume_3d.SetUserTransform(self.transform)
    renderer.AddVolume(self.volume_3d)

Thanks,

Luís Gonçalves

You need to tell VTK how to interpret scalar components using vtkVolumeProperty::SetIndependentComponents.

As a side note: avoid instantiating vtkOpenGLGPUVolumeRayCastMapper directly but instead use vtkGPUVolumeRayCastMapper and let VTK decide what specific implementation class to use.