Texturize 3D model (ray tracing)

Hi there,

I have created a 3D model from a stack of histological images. Now i would like to texturize/colorize this model by using the original rgb-images. Is there a way to project this “color” information on the model for example by ray casting (like it is done in volume rendering module)? Or any other way how I can achieve this? It should also work if i cut through the model.

I would appreciate any ideas or solutions. :slight_smile:

Thanks in advance
Michael

1 Like

You can visualize a 3D color volume using ray casting as described in this post:

1 Like

Thanks a lot Andras. :slight_smile: That worked so far, except for the fact

that the white space from my png-files is shown in the 3D view as a solid grey box (see picture). I’ve tried to mask my particle in the segmentation editor module (both the scalar volume and the vector volume) but that didnt help.

Do you know how to solve this problem?

Thanks and best regards,
Michael

As described in the linked post, you need an RGBA volume - the alpha channel containing transparency of voxels. If you want to make the background transparent then set alpha values of the background to 0.

Sorry to bother you again, but where do I have to set the alpha values? In the scalar volume or can I set this in the volume properties? Hope this question isn’t too stupid, but I’m still new to Slicer. Thanks!

There is no GUI for manipulating voxel values, but you can retrieve voxel values in the Python console as a numpy array (using slicer.util.arrayFromVolume), adjust the values of the alpha channel using standard numpy array manipulations, then update the volume with the changes (slicer.util.arrayFromVolumeModified). See example here.

Hello Andras,
that worked well, thanks :slight_smile: Is there a way to keep these settings when I save the whole scene as a medical record bundle? Currently, when I reload the scene from the bundle my modifications are not displayed anymore. Display node is observing the volume properties and the volume node.
How can I ensure to reload the scene in exactly the same state as I saved it?

Probably IndependentComponents property is not saved in the file. Probably you would just need to add a couple of lines to vtkMRMLVolumePropertyNode to read/write the property to XML.