walk_through_segment_3D#

crispy.pruning.pruning.walk_through_segment_3D(segment)[source]#

Traverse a 3D skeleton segment to obtain an ordered list of pixel coordinates.

This function processes a skeleton segment that does not contain branches or intersections and returns an ordered list of pixel coordinates. The traversal starts from the endpoint closest to the origin.

Parameters:

segment (ndarray) – A binary 3D array representing the skeleton segment. Non-zero values indicate skeleton pixels, and zero values represent the background.

Returns:

idx_list – A list of 3D coordinate tuples ordered by their position along the segment. The traversal begins from the endpoint nearest to the origin.

Return type:

list of tuple

Notes

  • This function assumes that the segment has exactly two endpoints and does not touch the edges of the array.

  • The traversal may fail if the segment width exceeds one pixel at any point due to imperfect skeletonization.

  • Endpoints are detected using the endPoints function.

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

Raises:

ValueError – If the segment has less than two pixels or more than one pixel-wide connectivity.