How to access resliced image data from vtkImageResliceMapper in VTK.js

Hi,

I’m trying to retrieve pixel data from a slice rendered using vtkImageResliceMapper in VTK.js. Specifically, I want to access the resliced output as a pixel array to count the occurrence of each pixel colour.

Initially, I used vtkImageReslice, but encountered image striping artefacts.

SincevtkImageReslice.setInterpolationMode() only supports NearestNeighbor, I switched to vtkImageResliceMapper, which supports linear interpolation and produces better visual results.
However, after switching, I can no longer access the resliced image data. Calling getCurrentImage() on the mapper returns null.

Is there a recommended way to extract the pixel data from the resliced output when using vtkImageResliceMapper?

There is a distinction between the two implementations: vtkImageReslice and vtkImageResliceMapper.

vtkImageReslice is a filter that generates image output, which can then be sent to a mapper for rendering or to another filter in the processing pipeline for further manipulation. In contrast, vtkImageResliceMapper acts as a mapper; it displays a slice from the 3D volume on the screen using the graphics API.

Although it is possible to obtain pixel output from the rendering process, important characteristics of the image data, such as data type and origin, may not be preserved. In summary, if you need an output data object for further processing, it is advisable to use a filter. This principle applies to all VTK processing objects.

Thank you for the quick response. I did try implementing linear interpolation with vtkImageReslice, but it was significantly slower than using vtkImageResliceMapper. From what I understand, the mapper uses the GPU, which explains the performance difference.

For my use case, I need both speed and access to the resulting pixel values. Do you have any suggestions on how I might achieve this?