Fill holes in mesh

Hi;
I have a 3D image (vtkImageData with holes) on which I applied Marching cubes and I get a 3d surface with small holes (see attached figure).

mesh

To deal with this problem, I have resampled the 3D image with sampledFactor of 0.5 before applying the marching cubes

here is the code:

		double resampledFactor =0.5;
		
		vtkSmartPointer<vtkImageReslice> resampledImage =
		vtkSmartPointer<vtkImageReslice>::New();
		resampledImage->SetInputData(imageData);
		
		int extent[6];
		extent[0] = ext[0];
		extent[1] = ext[1] /resampledFactor;
		extent[2] = ext[2];
		extent[3] = ext[3] /resampledFactor;
		extent[4] = ext[4];
		extent[5] = ext[5] / resampledFactor;
		
		resampledImage->SetOutputSpacing(0.5,0.5,0.5);
		resampledImage->SetOutputOrigin(0,0,0);
		resampledImage->SetOutputExtent(extent);
		resampledImage->SetInterpolationModeToLinear();
		resampledImage->Update();

The resulted surface is enhenced but it is still contains smalll holes. My question is how can I fill in holes in vtkImageData or in mesh in order to get a closed 3D surface without holes.

Thank’s in advance

Isosurface extracted from an unprocessed image is expected to be noisy. You can greatly improve quality by applying Gaussian smoothing, but that will also remove fine details. You can try non-linear filters, such as median or various anisotropic smoothing, which may preserve details while removing certain noise types. These filters (and many more) are available in “Simple filters” module.

However, most of the time you cannot extract structures by simple thresholding/isosurface extraction but you need to use various segmentation tools. You can find many of them in Segment Editor (and there are several extensions that installs provides additional ones).

-Thank you for response.

Im trying to create the model from the 3D coordinate points that are stored in the txt file (and not a segment). I use the Marching cubes algorithm. It looks like it´s not able to link individual points, and therefore holes are created in the model.

I tried vtkImageOpenClose3D.h to close the holes but it seems do not give good results .

        vtkSmartPointer<vtkImageOpenClose3D> openClose =
        vtkSmartPointer<vtkImageOpenClose3D>::New();
        openClose->SetInputData(imageData);
        openClose->SetOpenValue(255);
        openClose->SetCloseValue(0);
        openClose->SetKernelSize(5, 5, 5);
        //openClose->ReleaseDataFlagOff();
        openClose->GetOutput();
        openClose->GetCloseValue();
        openClose->GetOpenValue();
        openClose->Update();

What software produces this text file?
Do the coordinate correspond to a list of planar contours (coming from a DICOM RT structure set)?
Or some software lists each individual voxel value of a binary labelmap (that would be extremely inefficient)?

Hi Mr;

I have created points from segmentation and generated surface to do some tests. I have resapmled and used vtkImageOpenClose3D. Now it works fine (all holes are filled

thank’s