n_labels: int | None = None,
smoothing: bool = False,
smoothing_num_iterations: int = 50,
smoothing_relaxation_factor: float = 0.5,
smoothing_constraint_distance: float = 1,
output_mesh_type: Literal['quads', 'triangles'] = 'quads',
output_style: Literal['default', 'boundary'] = 'default',
scalars: str | None = None,
progress_bar: bool = False,
) PolyData[source]#

Generate labeled contours from 3D label maps.

SurfaceNets algorithm is used to extract contours preserving sharp boundaries for the selected labels from the label maps. Optionally, the boundaries can be smoothened to reduce the staircase appearance in case of low resolution input label maps.

This filter requires that the ImageData has integer point scalars, such as multi-label maps generated from image segmentation.


Requires vtk>=9.3.0.

n_labelsint, optional

Number of labels to be extracted (all are extracted if None is given).

smoothingbool, default: False

Apply smoothing to the meshes.

smoothing_num_iterationsint, default: 50

Number of smoothing iterations.

smoothing_relaxation_factorfloat, default: 0.5

Relaxation factor of the smoothing.

smoothing_constraint_distancefloat, default: 1

Constraint distance of the smoothing.

output_mesh_typestr, default: ‘quads’

Type of the output mesh. Must be either 'quads', or 'triangles'.

output_stylestr, default: ‘default’

Style of the output mesh. Must be either 'default' or 'boundary'. When 'default' is specified, the filter produces a mesh with both interior and exterior polygons. When 'boundary' is selected, only polygons on the border with the background are produced (without interior polygons). Note that style 'selected' is currently not implemented.

scalarsstr, optional

Name of scalars to process. Defaults to currently active scalars.

progress_barbool, default: False

Display a progress bar to indicate progress.


pyvista.PolyData Labeled mesh with the segments labeled.

See also


Generalized contouring method which uses MarchingCubes or FlyingEdges.


Function used internally by SurfaceNets to generate contiguous label data.


Sarah F. Frisken, SurfaceNets for Multi-Label Segmentations with Preservation of Sharp Boundaries, Journal of Computer Graphics Techniques (JCGT), vol. 11, no. 1, 34-54, 2022. Available online


See Contouring for a full example using this filter.