vtkGPUVolumeRayCastMapper -> SetMaskInput : vtkVolumePicker picks masked cells

Dear VTK users,

I am rendering volume data with vtkGPUVolumeRayCastMapper (and with vtkOpenGLGPUVolumeRayCastMapper)

I hide several parts by using the function SetMaskInput available with these 2 mappers. When I use vtkVolumePicker (or vtkCellPicker), I would expect not to pick masked cells… I would like to pick the cells located behind the masked cells.

However, the picker acts as if no cell was masked (see picture below)

Nevertheless, the picker works as expected when clipping planes are used to hide parts of the volume instead of a Mask.

Do I miss something, is there anything I should activate to be able to avoid picking masked cells ?
Many thanks in advance.
Best wishes,
Renaud.

I did not manage to solve this issue, but a (dirty) workaround I now use to be able not to pick masked cells is to fill masked voxels with a chosen value (often this value = 0), in a similar way as what is implemented in 3D Slicer to mask regions.

If someone knows a better way not to pick masked voxels, I would be very grateful to learn how you manage to do that. Many thanks in advance.

I have exactly the same problem with vtkCellPicker and a gpu volume render with a mask set. Did you ever manage to get this working without applying the mask to the input data? I would prefer to let the mapper do the masking if possible as it is one less copy of the data, and possibly a bit quicker as it is done on the GPU. I have had a look through the classes to see whether there is a ‘apply mask for picking’ property to set somewhere, but I have not found anything.

I am wondering if this should be raised as a bug as it seems like it will catch anyone out who is performing masking using the vtkGPUVolumeRayCastMapper SetMaskInput function, then subsequently trying to perform picking on the rendererd volume. As far as I see it, the user would be expecting the picking action to work on what they are looking at, rather than the un-masked volume render.

Hi Lebrun, I’m working on realizing cylinder mask to volume rendering of head bone. But I’m confused with how to use SetMaskInput or other relative api. Could you show some piece of the code of mask? Many thanks in advance.

Hi I would have to look a few hours in my code to create a working example and refresh my mind about how I did all that last year => however you can access the whole software and search where the mask things are coded : the whole code is available at : https://github.com/morphomuseum/MorphoDig and compiled versions and tutorials are available at https://morphomuseum.com/morphodig

1 Like

It looks pretty cool! I’ll study it. Thank you very much!

Setting mask input is really easy. Once you have set up volume rendering, call:

vrMapper.SetMaskTypeToBinary()
vrMapper.SetMaskInput(maskImageData)

If picking on the masked surface is important then probably the simplest is to actually blank out regions of the volume using the mask. For this, you can also use 3D Slicer (or take code from implementation in 3D Slicer):

2 Likes

@lassoan @renaud-lebrun Following your guide and demo, I create a tuber actor and use the intersection as mask on CT bone volume. It works! Many thanks!

1 Like

Very nice indeed :slight_smile:

Glad it worked. Note that if you want to implement neuroimaging applications using VTK then you can save a lot of time by using 3D Slicer as a basis. It already has all the tools to build a full neurosurgical visualization, intervention planning, and guidance workflow including DICOM import/export, segmentation (manual, semi-automatic, AI methods), registration, tractography, AR/VR display, live connection to tracking devices and commercial navigation systems, etc. Decades of development work, all open-source, and freely available to use, without any restrictions. By using all these existing features you can focus on working on your own new ideas that distinguish your system from all the existing similar systems.

Hi , I have rendered a volume using vtkGPUVolumeRaycastMapper, now I need to mask the volume using binary mask mentioned by @lassoan
Mapper.SetMaskTypeToBinary()
Mapper.SetMaskInput(maskImageData) , but the mask is not working. Does anyone knows any solution, or is anything to be done in addition.
For preparing the mask I have created a 3D numpy array of type unsigned char(ubyte) , filling some values with 255 and others with 0. I then converted this numpy array to vtkImageData.
Input volume data is a 3d numpy array of type unsigned 8 bit integer- Converted this to vtkImageData and set it as input to mapper as below:
mapper.SetInput(inputimage).
Volume is rendering, but mask is not working.Does anyone knows any solution, or is anything to be done in addition.