Correct Application of a Smoothing filter on an IsoSurface

vtkSmartPointer<vtkMarchingCubes> iso = vtkSmartPointer<vtkMarchingCubes>::New();
iso->SetInputConnection(NrrdFileReader->GetOutputPort());
iso->ComputeGradientsOn();
iso->ComputeScalarsOff();
iso->SetValue(0, 1);
iso->Update();

vtkSmartPointer<vtkWindowedSincPolyDataFilter> smoother = vtkSmartPointer<vtkWindowedSincPolyDataFilter>::New();
smoother->SetInputData(iso->GetOutput());
smoother->SetNumberOfIterations(20);
double passband = 0.3;
smoother->SetPassBand(passband);
smoother->BoundarySmoothingOff();
smoother->FeatureEdgeSmoothingOn();
smoother->SetEdgeAngle(180);
smoother->NonManifoldSmoothingOff();
smoother->NormalizeCoordinatesOff();
smoother->Update(); 

vtkSmartPointer<vtkPolyDataMapper> isoMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
isoMapper->SetInputConnection(smoother->GetOutputPort());
isoMapper->ScalarVisibilityOff();

vtkSmartPointer<vtkActor> isoActor = vtkSmartPointer<vtkActor>::New();
isoActor->SetMapper(isoMapper);
isoActor->GetProperty()->SetColor(namecolors->GetColor3d("Ivory").GetData());

vtkSmartPointer<vtkOutlineFilter> outline = vtkSmartPointer<vtkOutlineFilter>::New();
outline->SetInputConnection(NrrdFileReader->GetOutputPort());

vtkSmartPointer<vtkPolyDataMapper> outlineMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
outlineMapper->SetInputConnection(outline->GetOutputPort());
	
vtkSmartPointer<vtkActor> outlineActor = vtkSmartPointer<vtkActor>::New();
outlineActor->SetMapper(outlineMapper);

ren1->AddActor(outlineActor);
ren1->AddActor(isoActor);
ren1->SetBackground(namecolors->GetColor3d("SlateGray").GetData());

I had reconstructed a model from .nrrd file using the Marching cube algorithms.
I was trying to apply smoothing to the model above, but it doesn’t seem to change. I wanted to confirm, if I had done it properly. Also, I am not sure if the outline filter needs to be changed in this case.

Try turning off feature edge smoothing (FeatureEdgeSmoothingOff()) and see what happens. The resolution of the volume / data is so low that the end effect is to create many sharp edges, which then become constraints to the smoothing process.

Thanks Will, but it still gives me the same result. I am not sure if I’ve correctly applied the filter.

Thanks for trying. Can you send the data?

1 Like

See a correct usage of the filter for smoothing binary segmentations here:

Note that if the input image was highly anisotropic then you cannot remove the staircase artifacts (without significant loss of relevant details) with surface smoothing at the end of your processing pipeline. Instead, to avoid these artifacts you can resample the input grayscale image to be approximately isotropic, and then apply contour filter and surface smoothing. See more detailed explanation and instructions in the 3D Slicer forum and 3D Slicer User Manual.

2 Likes

Uploading: output_00126702-1-label.nrrd…

Will, PFA the file for the segmentation. Regards.

Thanks, I’ll take a look. Note that Andras works with this type of data much more than I do, so I would pay careful attention to what he wrote - I’m pretty sure he’s offering good advice.

Thank you Will and Andras, yes I 'm working on writing code for what Andras has shared as well. Will keep you guys posted as I am able to get the results from his method. Thanks again.