grid_skeleton#
- crispy.grid_ridge.grid_skeleton(coord, refdata, coord_in_xfirst=False, start_index=1)[source]#
Map CRISPy skeleton coordinates onto a reference image grid.
Takes CRISPy ridge coordinates and grids them onto a binary mask with the same shape as a reference image. The resulting mask highlights the skeletonized structure aligned to the grid.
- Parameters:
coord (ndarray) – Coordinates of the ridge points, shape (n, D), where n is the number of points and D is the dimensionality (2D or 3D).
refdata (ndarray) – Reference image array defining the grid dimensions.
coord_in_xfirst (bool, optional, default=False) – If True, assumes the input coordinates are ordered with x as the first axis. If False, assumes z is the first axis for 3D data or y for 2D data.
start_index (int, optional, default=1) – Starting index for mapping the skeleton coordinates to the reference grid.
- Returns:
mask – Binary mask with the same shape as refdata, where skeletonized points are set to 1 and all other points are 0.
- Return type:
ndarray
Notes
The coordinates are rounded to the nearest integer and adjusted for the starting index before mapping onto the reference grid.
This function supports both 2D and 3D data.
Examples
Map 3D ridge coordinates onto a reference image grid:
>>> import numpy as np >>> from crispy import grid_ridge >>> coords = np.array([[0, 0, 0], [1, 1, 1], [10, 10, 10]]) >>> ref_image = np.zeros((20, 20, 20)) # Reference image >>> mask = grid_ridge.grid_skeleton(coords, ref_image) >>> print(mask.shape) (20, 20, 20)