labels2listsOfPoints
- tomni.transformers.labels2listsOfPoints(labels: numpy.ndarray) numpy.ndarray [source]
Convert labeled regions into lists of points.
- Parameters
labels (np.ndarray) – An array where every pixel is labeled to indicate which object it belongs to. The labels should be non-negative integers.
- Returns
- A list of lists, where each inner list contains the (x, y) coordinates
of points belonging to the corresponding label. The list is organized such that output[label] contains the points for the label with value label. The label values must start from 0 and be contiguous integers.
- Return type
List[List[Tuple[int, int]]]
- Raises
ValueError – If the number of labels exceeds the supported limit.
Note
The function automatically determines the appropriate data type for labels based on their maximum value.
It uses sparse matrix operations to efficiently extract points for each label.