K-means¶
K-means partitions per-pixel feature vectors into \(k\) clusters by iteratively assigning each pixel to its nearest cluster center, then recomputing centers as the mean of their assigned pixels, until the assignment stops changing. It minimizes the within-cluster variance — the total squared distance from each pixel to its cluster’s center.
Unlike the other five clustering methods on this page, JuSPICE’s K-means clusters the raw, un-collapsed array directly, so every channel of a multi-channel image (e.g. all 8 channels of a multi-channel AFM scan) contributes to each pixel’s feature vector, rather than operating on a single grayscale/intensity channel. This makes it the natural choice when the meaningful structure in the data lives across channels, not just within one.
Accessible via spice.clustering.kmeans_clustering().
See also
SLIC Superpixels — K-means restricted to a local spatial neighborhood
Image Clustering — every other clustering algorithm