cornerstonejs / cornerstone3D

Cornerstone is a set of JavaScript libraries that can be used to build web-based medical imaging applications. It provides a framework to build radiology applications such as the OHIF Viewer.
https://cornerstonejs.org
MIT License
563 stars 288 forks source link

[Feature Request] Is it possible to display RGBA volume data in VolumeViewport? #777

Open mapseamoff opened 1 year ago

mapseamoff commented 1 year ago

What feature or change would you like to see made?

Hello! I'm trying to display RGBA volume in VolumeViewport, but I guess only RGB data is supported (via PhotometricInterpretation: 'RGB' in ImageVolume metadata). I've tried to replace imageData with custom vtkImageData, where scalarsArray is replaced with RGBA data, but in this case Cornerstone displays nothing in the viewport.

Why should we prioritize this feature?

This is needed to implement overlaying of existing volume with rgba-colored data, so some voxels in overlay volume must have zero alpha value.

sedghi commented 1 year ago

Can't you have the RGB volume and then fuse the other one on top? similar how we do it for pt ct fusion

https://www.cornerstonejs.org/live-examples/petct

mapseamoff commented 1 year ago

I guess no, I need to display RGB data on top of other volume. Since I can't set alpha = 0 for e.g. black color, the base volume is completely hidden by RGB volume. Currently my usecase can be achieved by adding vtkImageSlice actor to the viewport, but it would be great to do this via Cornerstone's setVolumesForViewports

sedghi commented 1 year ago

You can always right a colormap that can map black to 0 opacity, take a look here https://github.com/OHIF/Viewers/blob/master/extensions/tmtv/src/utils/colormaps/index.js

mapseamoff commented 1 year ago

I guess colormap maps scalar values to rgb(a) color, but I already have rgb-colored voxels (so non-scalar voxel values), so colormap is not applicable here. Am I missing something?

sedghi commented 1 year ago

I see, no you are right. so seems like the black (background) is the problem. hmmm, one option is to not encode as RGB and just apply the RGB aspect in the color transfer function, so just store non-rgb and take care of the background to 0 via scalar mapping? what do you think