fixed kmeans

pull/13383/head
Maria Dimashova 13 years ago
parent 7e06b18144
commit 74b38e978b
  1. 8
      modules/core/src/matrix.cpp

@ -2610,18 +2610,18 @@ double cv::kmeans( InputArray _data, int K,
double max_dist = 0;
int farthest_i = -1;
float* new_center = centers.ptr<float>(k);
float* _old_center = centers.ptr<float>(max_k);
float* old_center = temp.ptr<float>();
float* old_center = centers.ptr<float>(max_k);
float* _old_center = temp.ptr<float>(); // normalized
float scale = 1.f/counters[max_k];
for( j = 0; j < dims; j++ )
old_center[j] = _old_center[j]*scale;
_old_center[j] = old_center[j]*scale;
for( i = 0; i < N; i++ )
{
if( labels[i] != max_k )
continue;
sample = data.ptr<float>(i);
double dist = normL2Sqr_(sample, old_center, dims);
double dist = normL2Sqr_(sample, _old_center, dims);
if( max_dist <= dist )
{

Loading…
Cancel
Save