component_overlap#
- medicalimageanalysis.utils.mesh.surface.component_overlap(components_1, components_2, min_distance=0)[source]
Matches connected components from two meshes by overlap or proximity.
Workflow#
Pairs whose bounding boxes intersect are tested for overlap: surface intersection, or any point of one component enclosed by the other. Overlapping pairs are matched with distance 0.
Components left unmatched on both sides are paired if their nearest surface distance is <=
min_distance.
- param components_1:
Connected mesh components to compare (e.g. from
compute_components()). Surfaces are expected to be closed for the enclosed-point test.- type components_1:
list[pyvista.DataSet]
- param components_2:
Connected mesh components to compare (e.g. from
compute_components()). Surfaces are expected to be closed for the enclosed-point test.- type components_2:
list[pyvista.DataSet]
- param min_distance:
Maximum nearest-surface distance (mm) allowed when no direct overlap is found.
- type min_distance:
float, optional
- returns:
Match records
{'Components_1': i, 'Components_2': j, 'distance_mm': d}.- rtype:
list[dict]
Examples
>>> import pyvista as pv >>> from medicalimageanalysis.utils.mesh.surface import component_overlap >>> a = [pv.Sphere(radius=1), pv.Sphere(radius=1, center=(10, 0, 0))] >>> b = [pv.Sphere(radius=1, center=(0.5, 0, 0)), pv.Sphere(radius=1, center=(12.5, 0, 0))] >>> [(m['Components_1'], m['Components_2']) for m in component_overlap(a, b)] [(0, 0)] >>> [(m['Components_1'], m['Components_2']) for m in component_overlap(a, b, min_distance=1)] [(0, 0), (1, 1)]