When a cluster is empty for KMeans, it's better to give it the point from another cluster j that is the furthest one from center j.

pull/2026/head
Pierre-Emmanuel Viel 11 years ago
parent 26f5d2d639
commit d3ac1bc314
  1. 11
      modules/flann/include/opencv2/flann/kmeans_index.h

@ -759,10 +759,13 @@ private:
for (int k=0; k<indices_length; ++k) {
if (belongs_to[k]==j) {
belongs_to[k] = i;
count[j]--;
count[i]++;
break;
// for cluster j, we move the furthest element from the center to the empty cluster i
if ( distance_(dataset_[indices[k]], dcenters[j], veclen_) == radiuses[j] ) {
belongs_to[k] = i;
count[j]--;
count[i]++;
break;
}
}
}
converged = false;

Loading…
Cancel
Save