开发者

OpenCV K-Means (kmeans2)

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 possibl开发者_如何学Pythone? 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!


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜