Extract volume from vtkImageData

Hi everyone,

I’m running a segmentation which produces various separate volumes that are then added to a vtkRenderer as vtkActors.

The problem is, that the bounds of this volumes (vtkImageData) correspond to the bounds of the input from which they were segmentated.

I need to have the segmentated volumes in their corresponding actual sizes so I can pick them correctly without one overlapping the other. I’ve been trying with vtkMarchingCubes, but I’m not really sure how to use this class or if it is the right one.

When I do this:

        extractor = vtk.vtkMarchingCubes()
        extractor.SetInputData(image_data)
        extractor.SetValue(0, userPrefs.get_value("Modelling Threshold"))
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(extractor.GetOutputPort())
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)

I get the error: vtkMarchingCubes ERR: Scalar array must only have a single component.

I also tried vtkFlyingEdges3D and the volumes are extracted but very poorly (missing parts). How can I make this better?

Can someone enlighten me on how to extract the volumes from the full sized ImageData?
Thanks in advance!

Well, is your array a scalar ?