bodyPoints#

crispy.pruning.pruning.bodyPoints(skel)[source]#

Identify body points in a skeletonized structure.

Detects body points in a 2D or 3D skeleton. Body points are defined as pixels with exactly two neighbors in the skeleton, based on 2-connectivity in ND.

Parameters:

skel (ndarray) – Binary array representing the skeletonized structure. Non-zero values represent skeleton points, and zero values represent the background.

Returns:

pt – Binary array with the same shape as skel, where body points are set to True.

Return type:

ndarray

Notes

  • Body points are computed by identifying skeleton points with exactly two neighbors under the specified connectivity rules.

  • This function supports both 2D and 3D skeletons, adjusting connectivity checks based on the dimensionality.

  • This code is based on the 2D version seen in FilFinder (v1.7.2) by Eric Koch.

Examples

Detect body points in a 2D skeleton:

>>> import numpy as np
>>> from crispy import grid_ridge
>>> skel = np.zeros((5, 5), dtype=bool)
>>> skel[2, 1:4] = True
>>> body_pts = grid_ridge.bodyPoints(skel)
>>> print(body_pts)
[[False False False False False]
 [False False False False False]
 [False  True  True  True False]
 [False False False False False]
 [False False False False False]]