local_stats.cluster
This module contains the Cluster class. This is a convenient way to handle the output of scikit-learn’s DBSCAN algorithm.
- class local_stats.cluster.Cluster(arr: numpy.ndarray)[source]
Bases:
object
For tracking clusters of pixels.
- classmethod from_DBSCAN(X: numpy.ndarray, labels_) List[local_stats.cluster.Cluster] [source]
Takes the input and output of scikit-learn’s DBSCAN algorithm. Returns a list of cluster objects. Note that, because of naive use of lists, this will slow down if len(labels_) is around 10^5-10^7-ish.
- intensity(arr: numpy.ndarray) float [source]
Returns the sum of this cluster’s pixels in arr.
- Parameters
arr – The image to sum over.
- Returns
The area underneath this cluster in the image array passed as an argument.
- property mean
Returns the mean pixel value.
- property pixel_indices
Returns pixel indices in a np.where compatible format.
- property size
Returns the number of pixels in the cluster.