..cfunction:: int cvKMeans2(const CvArr* samples, int nclusters, CvArr* labels, CvTermCriteria termcrit, int attempts=1, CvRNG* rng=0, int flags=0, CvArr* centers=0, double* compactness=0)
Splits set of vectors by a given number of clusters.
:param samples:Floating-point matrix of input samples, one row per sample
:param nclusters:Number of clusters to split the set by
:param labels:Output integer vector storing cluster indices for every sample
:param termcrit:Specifies maximum number of iterations and/or accuracy (distance the centers can move by between subsequent iterations)
:param attempts:How many times the algorithm is executed using different initial labelings. The algorithm returns labels that yield the best compactness (see the last function parameter)
:param rng:Optional external random number generator; can be used to fully control the function behaviour
:param flags:Can be 0 or ``CV_KMEANS_USE_INITIAL_LABELS`` . The latter
value means that during the first (and possibly the only) attempt, the
function uses the user-supplied labels as the initial approximation
instead of generating random labels. For the second and further attempts,
the function will use randomly generated labels in any case
:param centers:The optional output array of the cluster centers
:param compactness:The optional output parameter, which is computed as :math:`\sum_i ||\texttt{samples}_i - \texttt{centers}_{\texttt{labels}_i}||^2`
after every attempt; the best (minimum) value is chosen and the
corresponding labels are returned by the function. Basically, the
user can use only the core of the function, set the number of
attempts to 1, initialize labels each time using a custom algorithm
:param is_equal:The relation function that should return non-zero if the two particular sequence elements are from the same class, and zero otherwise. The partitioning algorithm uses transitive closure of the relation function as an equivalency criteria