Question

I'm using Opencv's K-means implementation to cluster a large set of 8-dimensional vectors. They cluster fine, but I can't find any way to see the prototypes created by the clustering process. Is this even possible? OpenCV only seems to give access to the cluster indexes (or labels).

If not I guess it'll be time to make my own implementation!

Was it helpful?

Solution

I can't say I used OpenCV's implementation of Kmeans, but if you have access to the labels given to each instance, you can simply get the centroids by calculating the average vector of instances belong to each of the clusters.

OTHER TIPS

As of (at least) OpenCV 2.0, there is the way to retrieve cluster centers (see the latest argument):

double kmeans( const Mat& samples, int clusterCount, Mat& labels,
  TermCriteria termcrit, int attempts,
  int flags, Mat* centers );

http://opencv.willowgarage.com/documentation/cpp/clustering_and_search_in_multi-dimensional_spaces.html#cv-kmeans

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top