get_2d_length#
- crispy.grid_ridge.get_2d_length(skl3d)[source]#
Calculate the sky-projected length of a 3D skeleton.
Computes the length of a skeleton structure when projected onto a 2D plane. The projection is performed by collapsing the third dimension of the input 3D skeleton array.
- Parameters:
skl3d (ndarray) – 3D binary array representing the skeletonized structure, where True or 1 indicates skeleton points and False or 0 represents the background.
- Returns:
length – The total number of pixels in the projected 2D skeleton.
- Return type:
Notes
The function collapses the 3D skeleton along the third axis using a logical OR operation and then applies 2D skeletonization to the resulting binary image.
This method is useful for evaluating the extent of structures in position-position space regardless of the velocity axis.
Examples
Compute the 2D length of a 3D skeleton:
>>> import numpy as np >>> from skimage.morphology import skeletonize >>> from crispy import grid_ridge >>> skl3d = np.zeros((10, 10, 10), dtype=bool) >>> skl3d[0, 0, :] = True # A straight skeleton in 3D >>> length = grid_ridge.get_2d_length(skl3d) >>> print(length) 1