# Wolfram Language & System 10.0 (2014)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.
BUILT-IN WOLFRAM LANGUAGE SYMBOL

# 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 at most 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 at most n clusters in image.

## Details and OptionsDetails and Options

• ClusteringComponents[source,DistanceFunction->f] treats pairs of elements, in source as being less similar when their distances are larger.
• For images and real data, ClusteringComponents by default effectively uses the Euclidean distance function EuclideanDistance to determine the similarity of elements.
• For lists of True and False, ClusteringComponents by default uses a distance function based on the normalized fraction of elements that disagree.
• For lists of strings, ClusteringComponents by default uses a distance function based on the number of point changes needed to get from one string to another.
• Other distance functions can be specified by setting DistanceFunction. Possible settings are:
•  ManhattanDistance Manhattan or "city block" distance EuclideanDistance Euclidean distance SquaredEuclideanDistance squared Euclidean distance NormalizedSquaredEuclideanDistance normalized squared Euclidean distance CosineDistance angular cosine distance CorrelationDistance correlation coefficient distance
• A Method option can be used to specify different methods of clustering. Possible settings include:
•  "Agglomerate" find clustering hierarchically "Optimize" find clustering by local optimization "KMeans" -means clustering algorithm "PAM" find clustering by partitioning around medoids
• ClusteringComponents accepts a option that is used to control the creation of the initial set of seeds.
• ClusteringComponents also works with Image3D objects.

## ExamplesExamplesopen allclose all

### Basic Examples  (3)Basic Examples  (3)

Label two clusters of values in a list:

 Out[1]=

Cluster analysis of an MR image:

 Out[1]=

Find a color segmentation of a satellite image:

 Out[1]=