label_ridge#

crispy.grid_ridge.label_ridge(coord, eps=1.0, min_samples=5)[source]#

Label unconnected ridges using DBSCAN clustering.

Applies the DBSCAN algorithm to identify and label distinct, unconnected ridge structures in the input coordinates.

Parameters:
  • coord (ndarray) – Coordinates of the ridge points, shape (n, D), where n is the number of points and D is the dimensionality.

  • eps (float, optional, default=1.0) – Maximum distance between two points to be considered part of the same ridge.

  • min_samples (int, optional, default=5) – Minimum number of points required to form a cluster.

Returns:

labels – Cluster labels for each point, shape (n,). Points labeled -1 are considered noise.

Return type:

ndarray

Notes

  • DBSCAN is a density-based clustering algorithm that groups points based on spatial proximity. Points that do not belong to any cluster are assigned the label -1.

  • This function requires scikit-learn for the DBSCAN implementation.

Examples

Label ridge points in a 2D space:

>>> import numpy as np
>>> from crispy import grid_ridge
>>> coords = np.array([[0, 0], [1, 1], [2, 2], [10, 10], [11, 11]])
>>> labels = grid_ridge.label_ridge(coords, eps=2.0, min_samples=2)
>>> print(labels)
[ 0  0  0  1  1 ]