This post has NOT been accepted by the mailing list yet.
This post was updated on .
I've been trying to cluster some images based on opencv's cvKMeans2() function.
My problem is when I use as features, in "points", the mean value for the pixel in red channel, the mean value for the pixel in green channel and the mean value for the pixel in blue channel (3x3 neighbourhood).
I computed these means in separate functions for each channel.
Below is the one for the the blue channel.
// (3)run k-means clustering algorithm to segment pixels in RGB color space
cvKMeans2( points, NO_CLUSTERS, clusters,
cvTermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 100, 5.0 ), 5, 0, 0, centers, 0);
// (4)make a each centroid represent all pixels in the cluster
//cluster which u selected outputs.
//cluster which u didn't select is painted black color.
//generate saved file name.
for(i=0; i<size; i++)
int idx = clusters->data.i[i];
if(j == idx)
dst_img->imageData[i*3+0] = srcImg->imageData[i*3+0];
dst_img->imageData[i*3+1] = srcImg->imageData[i*3+1];
dst_img->imageData[i*3+2] = srcImg->imageData[i*3+2];
Can someone help me, please? I can't figure out what is wrong.
And also, how many features cand I have in points? If i also want to compute the standard deviation for each channel and set it as feature in points, what should I do?