only_main_component#
- medicalimageanalysis.utils.mesh.surface.only_main_component(mesh)[source]
Extracts the largest connected component (by point count) of a mesh.
- Parameters:
mesh (pyvista.PolyData) – Input mesh which may contain multiple disconnected components.
- Returns:
The largest connected component as a surface, or the input mesh if it has a single component.
- Return type:
pyvista.PolyData
Examples
>>> import pyvista as pv >>> from medicalimageanalysis.utils.mesh.surface import only_main_component >>> big = pv.Sphere(radius=2, theta_resolution=40, phi_resolution=40) >>> small = pv.Sphere(radius=0.5, center=(5, 0, 0)) >>> only_main_component(big.merge(small)).n_points == big.n_points True