diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index dddca6bf60..364e6f5114 100644 --- a/modules/core/src/matrix.cpp +++ b/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(k); - float* _old_center = centers.ptr(max_k); - float* old_center = temp.ptr(); + float* old_center = centers.ptr(max_k); + float* _old_center = temp.ptr(); // 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(i); - double dist = normL2Sqr_(sample, old_center, dims); + double dist = normL2Sqr_(sample, _old_center, dims); if( max_dist <= dist ) {