Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

i don't see any gain in transforming the angles to 2d points, but for now, you probably wanted this:

Mat points(angles.size,2, CV_32F);
for (int j = 0; j < angles.size(); j++) {
    float angle = 2 * angles[j][1]; 
    float c = cos(angle);
    float s = sin(angle);
    points.at<float>(j,0) = c;
    points.at<float>(j,1) = s;
}
vector<int> labels; // if k==3, each point gets a label 0,1,2
TermCriteria term(TermCriteria::EPS + TermCriteria::MAX_ITER, 10, 1.0);
kmeans(points, k,  labels, term, 10, KMEANS_PP_CENTERS);