Apply Laplacian smoothing using Python script

how can i set smoothing effect to laplacian filter type in scriptable module script ??

Segment editor smoothing effect uses vtkWindowedSincPolyDataFilter, which works better than Laplacian filter. The main problem with Laplacian filter is that it reduces segment volume.

See this example how to apply Smoothing effect from Python script:

Change SmoothingMethod from MEDIAN to JOINT_TAUBIN to use vtkWindowedSincPolyDataFilter instead of median filter.

Ahh… I’m already using this one…
Alright so this is the best smoothing technique …
Thanks :slight_smile:

Can i repeat same code of segmentation to add multiple segment in same model .

To fuse segments, you can use Logical operators effect.

You can merge segments (boundaries between them is kept) if you use the direct file export tool that has been added recently to the nightly build - see Save segmentation directly to STL or OBJ files

You can merge models one by one using Merge Models module.

thanks it works and gives nice output , but how can i do this by adding code into this script ?? https://gist.github.com/lassoan/1673b25d8e7913cbc245b4f09ed853f9

and thanks for the support :slight_smile:

Could you describe what you would like to do? Develop a new interactive Slicer module that does this? Or apply this processing in a batch mode on a large number of images?

You may find this tutorial useful: https://www.slicer.org/wiki/Documentation/Nightly/Training#Slicer4_Programming_Tutorial

I’m trying to make a batch file which will process the fbx file with different segmentation part in a single file.
i’m already using your script to make segmentation and save output in fbx using fbx exporter, but now im using latest nightly build so i want use the export segmentation feature using script.

thanks :slight_smile:

You can use slicer.modules.segmentations.logic().ExportSegmentsClosedSurfaceRepresentationToFiles(…) method.

Thanks Its working perfectly… :slight_smile:

Hi Andras,
Is the sinc filter in model maker the same as the segment editor?

Regards,
Saima Safdar

There are a few differences.

Segment Editor performs the same joint smoothing algorithm as Model maker, but then converts back the result into binary labelmap representation, so that it can be appropriately visualized and further edited. In contrast, Model maker creates a model that is not editable anymore.

Segment Editor performs a slight additional anti-aliasing filtering during generation of the closed surface representation.

Segment Editor can handle overlapping segments, while the Model maker cannot