ClusteringComponents
ClusteringComponents[array] gives an array in which each element at the lowest level of array is replaced by an integer index representing the cluster in which the element lies.
ClusteringComponents[array,n] finds n clusters.
ClusteringComponents[array,n,level] finds clusters at the specified level in array.
ClusteringComponents[image] finds clusters of pixels with similar values in image.
ClusteringComponents[image,n] finds n clusters in image.
Please visit the official Wolfram Language Reference for more details and examples on core symbols.