Color scalar overlay on VTK models


Is it possible to overlay a color scalar value from an RGB image on a VTK model in Slicer?

I tried to setup the color scalar in the following way but when the model is displayed in Slicer, it does not show the image scalar and defaults to another color table.

vtkSmartPointer<vtkUnsignedCharArray> ColorArray = vtkSmartPointer<vtkUnsignedCharArray>::New();
...ColorArray initialized here...


In the model module, have you scrolled down to the Scalars collapsible button to enable scalar colorization?

1 Like

Hello Priya.

When you say color scalar from an RGB image, does that mean that you want to apply a texture to a model? If so, you can have a look at GPU-based Projective Texture Mapping in a Loadable Module and see if you find some answers there.

If what you really want is applying scalar color values, you can have a look at for an example on mapping RGBA scalars to a model (this is a VTK example, but you can use it in 3D Slicer. To enable the visualization of scalars you can use the Models module as suggested by @adamrankin or programmatically by calling vtkMRMLModelDisplayNode::ScalarVisibilityOn() ( from the vtkMRMLModelDisplayNode corresponding to your vtkMRMLModelNode.

I hope this helps.

Thank you, Adam and Rafael.

I am looking to apply a texture on the model. I still seem to have a problem displaying texture on the model.

I have computed the color at every point and I am trying to save the texture as a scalar for the model. I am able to display the texture as a scalar field on the model. However, the color mapping seems completely off and the original colors of the texture are not displayed. As a check, when I use the this->ModelDisplayNode->SetAndObserveColorNodeID("vtkMRMLColorTableNodeGrey"); the texture shows correctly on the model, although in grayscale. I have set AutoScalarRange to zero and disabled the choice of the ColorNode but still the original colors of the texture are not being displayed.


This topic should answer your questions, but feel free to follow up here, if something is not clear: