Slicer quit when using vtkStatisticalOutlierRemoval

Hello!
I am trying to extract enclosed points of a point cloud inside a polydata using VTK.
Extracting the points (with vtkExtractEnclosedPoints) seems to work. However, there are outlier points that aren’t inside the polydata that are still there.
I’m trying to remove them using vtkStatisticalOutlierRemoval but Slicer crashes when I call the Update() function. I have tried using vtkRadiusOutlierRemoval but it does not seem to do anything (but it doesn’t make Slicer crash.)

I have created a C++ script independant from Slicer and used vtkStatisticalOutlierRemoval there and things are working well.

Here is my code:

vtkNew<vtkExtractEnclosedPoints> extract;
extract->SetSurfaceData(customShape);
extract->SetInputData(mosaic);
extract->CheckSurfaceOn();
extract->Update();
		
vtkNew<vtkStatisticalOutlierRemoval> removal;
removal->SetInputConnection(extract->GetOutputPort());
removal->SetSampleSize(25);
removal->Update(); //Slicer crashes here

Am I doing something wrong?

Kind regards,

Elise

This is a pure VTK issue, but if you provide sample data (customShape and mosaic polydata) that reproduce the issue then we can have a quick look.

Hello! Sorry for the late reply.

I’ve solved the issue by using a markup closed curve to draw the region of interest. It’s quicker to compute and creates a cleaner shape.

I cannot share the mosaic but the issue is the same using randomly generated points (like on the ExtractEnclosedPoints example).

The customShape is actually the closedSurfacePolyData inside the updateBrushModel function in the scissor script (qSlicersegmentBreastScissorWidget) on the SegmentEditor. My guess is that it might have tiny polygons and points but i’m not sure.

Here is the customShape with a test script.

This example works well for me with using customShape.vtk as input file, on Windows, with Slicer’s VTK version, both in debug and in release modes.

Sorry for the late reply, it seems like I’ve managed to make it work by using
vtkVertexGlyphFilter before displaying the polydata :sweat_smile:
Thank you for your help!

1 Like