Ask Your Question

canavaroski90's profile - activity

2019-08-09 14:51:28 -0600 received badge  Popular Question (source)
2014-11-04 11:02:04 -0600 commented answer how to get new center points in kmeans

that would be nice to have :)

2014-11-04 10:15:20 -0600 commented answer how to get new center points in kmeans

thank you for your response. actually i started to write a method exactly same with the one you suggested. however i wonder if there is any other (faster or one-line-code) method instead of writing 2 nested for loops? i mean a method which returns a vector contains the points which has a value that i interested.

2014-11-04 10:12:25 -0600 received badge  Supporter (source)
2014-11-04 10:12:20 -0600 received badge  Scholar (source)
2014-11-04 08:12:23 -0600 commented answer how to get new center points in kmeans

thank you for your answer but know i recognize that kmeans is not working the way i think. i used to use matlab for fast prototyping in image process operations, however, opencv and matlab functions may differ occasionally. if i give all image to kmeans method in matlab it returns new centroids without an effort.

2014-11-04 08:08:10 -0600 commented question how to get new center points in kmeans

so here is a new question; how can i get coordinates of all pixels whose value is 255 and write them into a new Mat object?

2014-11-04 08:07:30 -0600 commented question how to get new center points in kmeans

nope, trying to seperate white area in 4 section and find theirs centroids. however, as i understood, kmeans algorithm takes the 2D matrix as a complete feature vector set. in example, in my question 2D vector has been given as a parameter to kmeans function, and it is 91x53 matrix. so, kmeans recognizes it as 53 samples with 93 features and when it finishes its job, gives me newcenters which are calculated by looking 93 features of all 53 samples in complete vector set. that is why i'm getting newcenters matrix in sizes of 91x4 when i request for 4 clusters. if i can get the coordinates of all pixels whose value is 255, put those coordinates to a matrix and give it to kmeans, it will calculate me new points as well.

2014-11-04 06:57:01 -0600 asked a question how to get new center points in kmeans

hi,

trying to get new center points of newly created clusters with kmeans function. applying kemeans function as below;

kmeans(tmpsp[1], 4, labels, TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 10, 1.0/*CV_TERMCRIT_ITER, 1, 1.0*/), 3, KMEANS_RANDOM_CENTERS, newCenters);

and this is tmpsp[1] dataset (actually it is an image with the size of 91x53, and the type is CV_32F); image description

this is labels, it contains numbers from 0 to (cluster count-1), it is in size of 1x53;

image description

and this is newCenters, matrix in size of 94x53;

image description

1) how can i get centroids of found clusters? i need accurate x and y points for each clusters. 2) how can I give initial centroids?

thanks.