简体   繁体   中英

OpenCV - KMeans2 resulting in many empty clusters

I'm using OpenCV's (Python) kmeans2 function to cluster a set of SURF features extracted from a set of images.

cv.KMeans2(mat,CLUSTER_COUNT,labels,(cv.CV_TERMCRIT_ITER,100,1.0),centers = cent)

I'm running it on a set of around 50,000 features, setting my CLUSTER_COUNT to 2000. However I only get 253 clusters which are non-empty. The remaining clusters have no features assigned to them.

I'm not sure what OpenCV's implementation of K-Means looks like, but I would have thought that when there is an empty cluster, the centre is reassigned or something?

Is there something wrong with the way I am calling it or is this the expected behaviour?

Maybe try cv2.kmeans instead which is easier to understand. If the problem remains please let us know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM