Getting output of a widget as ImageData

Hello, when using the ImageCroppingWidget (example here) is it possible to get the ImageData of the object?

It is hinted here that the underlying volume from widgets are possible to save as ImageData using vtkXMLImageDataWriter, and thats exactly what i am trying to do.

Setting vtkVolume as the input yields an error since the vtkVolume class doesn’t have the getExtent function (source)

const writer = vtkXMLImageDataWriter.newInstance();
// writer.setCompression(true);
const data = writer.write(vtkVolume);

I have tried getting the ImageData object from the mapper itself but i couldn’t find a function to get the output data from the mapper in the documentation of the VolumeMapper, AbstractMapper or Mapper. I have also tried to find a function that crop widget itself but as far as i can tell the cropwidget usess the VolumeMapper to do the actual cropping while itself is just providing a interface for the input slice planes.

My questions are

  • Is there a straightforward way to get the output data from Volume, VolumeMapper or WidgetStates?
  • If so could they be combined with other widgets to get a single ImageData?
  • If not is there a way to get the ImageData from the model instead of the publicAPI using the get function?
  • If not is the recommended method to get cropping parameters from the widget and apply it to ImageCropFilter in the background, essantialy recomputing the cropping operation?


For anyone else with the same issue, i went with "geting cropping parameters from the widget and apply it to ImageCropFilte in the background" everything works as expected and computation overhead seems to be minimal.

Here is the code to update the filter:

let cropFilter = ...