branchedPoints#

crispy.pruning.pruning.branchedPoints(skel, endpt=None)[source]#

Identify branch points in a skeletonized structure.

Detects branch points in a 2D or 3D skeleton. Branch points are defined as skeleton pixels that are not endpoints or body points. If no endpoints are provided, they are computed automatically.

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

  • endpt (ndarray, optional) – Precomputed binary array of endpoints in the skeleton. If None, the function calculates the endpoints internally.

Returns:

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

Return type:

ndarray

Notes

  • Branch points are identified by excluding body points and endpoints from the skeleton.

  • The function automatically adjusts for 2D or 3D skeletons using appropriate connectivity rules.

  • This function relies on bodyPoints to determine body points and endPoints to calculate endpoints if endpt is not provided.

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

Examples

Detect branch points in a 2D skeleton:

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