Export colorized volume to .gltf

Dear community:
I am starting to use the colorize volume extension, got my colorized volume, but can´t export it to .gltf through the OpenAnatomy export extension. My objective is to show the colorized volume online.
Any hints would be welcomed.
Best regards,

No, you won’t be able to do that since Colorized Volumes are RGBA image data but gltf only support polygonal surface data.

1 Like

Thanks, Steve. This means that this module is only standalone for Slicer? I mean, its rendering is not displayable by the Online3DViewer, for instance?
Best,
Rafael

3dviewer can only display surface.models. try the Glance viewer from Kitware if you want to see the colorized voxels. I believe it supports rgb images

1 Like

Hello,
An alternative to Kitware Glance is Kitware Volview, that is specialized in rendering of medical volumes. It is also a little bit more maintained.
They are both based on vtk.js, and there are a lot of useful new features that are not used yet in Glance/Volview, so you could try using an example to make your own viewer.
https://volview.kitware.app/

1 Like

@Rafael_V_Monteiro let us know what you find if you try VolView and/or Glance. In addition to vtk.js in native javascript, there is also a path to use traditional C++ VTK with WebAssembly to render in browsers. Both of these rely on WebGL which can in theory render the RGBA volumes generated by the ColorizeVolume module, but I don’t know if those code paths have been debugged on the WebGL side of things in either C++ VTK or vtk.js. It took a while to get it fixed in the OpenGL version.

1 Like

Absolutely Steve. I´ll look into it and report back.
Thank you!
Rafael

Dear @pieper , @muratmaga , @Thibault_Bruyere:
I tried to play with the colorized model and displayed the model with the suggested viewers, Glance and Volview.
My colorized model was as below:

The only way I found out to export it to rgb capable formats was through the data module, right click on the colorized volume and export to file. The formats I found reasonable were the .nrrd and .vtk. I tried to view both formats on the viewers above quoted. VolView was able to open both .vtk and .nrrd files, results below:


nrrd

vtk

Glance was able to open only .nrrd format:

Its clear that none of them was able to reproduce the details shown in slicer.
Any suggestions were to go from here? Very thanks in advance,
Rafael

You cannot save a volume rendering, colorized or not. It is just a visual representation of volumetric data. I suggest reading this thread where this was discussed in detail:

1 Like

Thanks for testing this @Rafael_V_Monteiro. As noted above, in order to implement this feature we needed to fix the shader in VTK C++ to support using the alpha channel as opacity and configure the rendering pipeline to use that mode. I’m not sure any of the web based rendering systems support that configuration. There’s nothing in theory that prevents it from working, but it may require debugging and also proper configuration to replicate the view you see in Slicer. Making this work probably requires learning the source code and tracing the rendering path for RGBA mode (need to work in javascript, webgl, glsl, …).

1 Like

@Rafael_V_Monteiro in all your tests, the volume rendering was done with “independent components” flag enabled. Independent component means that the scalar components of the volume are rendered independently (not as a colored voxel). You need to set volumeProperty.SetIndependentComponents(false) if you want color rendering. For more realistic rendering you also need to carefully set up transfer functions, lighting, volumetric screen-space ambient occlusion, etc.

If you use a recent C++ VTK version then you don’t need any code change. Not all these features are available in vtk.js (and if they are then similar fixes may be needed as in C++ VTK), so I would recommend to use WebAssembly VTK in your web browser.

1 Like

I will look into, thanks @cpinter !

Based on the reactions I may have misunderstood something and just reacted without seeing the whole picture. But it may be useful regardless…

1 Like

Dear @pieper, this seems beyond my programming capabilities…But I will study it anyway to see if I get someplace.
Best regards,

Thank you @lassoan , I will do the modification in the volume rendering to see what happens. I also will give a try to vtk.js, maybe it is the way.
Best regards,