pyvista.ImageDataFilters.contour_labeled

pyvista.ImageDataFilters.contour_labeled#

ImageDataFilters.contour_labeled(
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.

Note

Requires vtk>=9.3.0.

Deprecated since version 0.45: This filter produces unexpected results and is deprecated. Use contour_labels() instead. See pyvista/pyvista#5981 for details.

To replicate the default behavior from this filter, call contour_labels with the following arguments:

image.contour_labels(
    boundary_style='strict_external',  # old filter strictly computes external polygons
    smoothing=False,  # old filter does not apply smoothing
    output_mesh_type='quads',  # old filter generates quads
    pad_background=False,  # old filter generates open surfaces at input edges
    orient_faces=False,  # old filter does not orient faces
    simplify_output=False,  # old filter returns multi-component scalars
)
Parameters:
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.

Returns:
pyvista.PolyData

pyvista.PolyData Labeled mesh with the segments labeled.

See also

pyvista.DataSetFilters.contour

Generalized contouring method which uses MarchingCubes or FlyingEdges.

pyvista.DataSetFilters.pack_labels

Function used internally by SurfaceNets to generate contiguous label data.

References

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 http://jcgt.org/published/0011/01/03/

https://www.kitware.com/really-fast-isocontouring/

Examples

See Contouring for a full example using this filter.