segment_len#

crispy.pruning.pruning.segment_len(wlk_idx, remove_axis=None)[source]#

Calculate the length of a skeleton segment.

This function computes the length of a skeleton segment from an ordered list of its pixel coordinates. The length is calculated as the sum of Euclidean distances between consecutive pixels. Optionally, a specified axis can be excluded from the calculation, which is useful for computing sky-projected lengths.

Parameters:
  • wlk_idx (list of tuple) – Ordered list of pixel coordinates representing the skeleton segment.

  • remove_axis (int, optional, default=None) – Axis to exclude from the length calculation. If None, the full length is computed in all dimensions.

Returns:

length – The computed length of the skeleton segment.

Return type:

float

Notes

  • The calculated length may underestimate the actual length by approximately one pixel due to measuring from the center of each pixel.

  • Excluding an axis (e.g., velocity in PPV space) computes the sky-projected length.