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)
Parameters:
- samples – Floating-point matrix of input samples, one row per sample
- nclusters – Number of clusters to split the set by
- labels – Output integer vector storing cluster indices for every sample
- termcrit – Specifies maximum number of iterations and/or accuracy (distance the centers can move by between subsequent iterations)
- 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)
- rng – Optional external random number generator; can be used to fully control the function behaviour
- 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
- centers – The optional output array of the cluster centers
- compactness – The optional output parameter, which is computed as 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 (flags=CV_KMEAN_USE_INITIAL_LABELS) and, based on the output compactness or any other criteria, choose the best clustering.
The function cvKMeans2() implements a k-means algorithm that finds the centers of nclusters clusters and groups the input samples around the clusters. On output, contains a cluster index for samples stored in the i-th row of the samples matrix.
文章標籤
全站熱搜
留言列表