#include <iostream>
// static void help()
// {
// cout << "\nThis program demonstrates kmeans clustering.\n"
// "It generates an image with random points, then assigns a random number of cluster\n"
// "centers and uses kmeans to move those cluster centers to their representitive location\n"
// "Call\n"
// "./kmeans\n" << endl;
// }
int main( int /*argc*/, char** /*argv*/ )
{
const int MAX_CLUSTERS = 5;
{
};
for(;;)
{
int k, clusterCount = rng.
uniform(2, MAX_CLUSTERS+1);
int i, sampleCount = rng.
uniform(1, 1001);
clusterCount =
MIN(clusterCount, sampleCount);
std::vector<Point2f> centers;
/* generate random sample from multigaussian distribution */
for( k = 0; k < clusterCount; k++ )
{
Mat pointChunk = points.
rowRange(k*sampleCount/clusterCount,
k == clusterCount - 1 ? sampleCount :
(k+1)*sampleCount/clusterCount);
}
double compactness =
kmeans(points, clusterCount, labels,
for( i = 0; i < sampleCount; i++ )
{
int clusterIdx = labels.
at<
int>(i);
}
for (i = 0; i < (int)centers.size(); ++i)
{
}
cout << "Compactness: " << compactness << endl;
if( key == 27 || key == 'q' || key == 'Q' ) // 'ESC'
break;
}
return 0;
}