How does kmeans decide which centroid the observation goes to when they have same mean? And is it possible to use 1d data matrix (n-by-1)?

3 views (last 30 days)
I've been doing color image segmentation using kmeans and it does wonders. However, this question has been bugging me as long and I still yet to find an answer for it.
Example (I'll use one data point and 4 cluster centroids):
data point, A = [3,4]
cluster centroid = [0,8;6,8;0,0;6,0]
Note that the (Euclidean distance) mean of A to all 4 cluster centroids is same = 5
How does kmeans decide which centroid A belongs to? Does it depends on the parameter we set? (eg using different distance measure, number of replicates)
I'm using three components of RGB for my image segmentation, thus it makes me even more confused.
Regarding the observation, is it possible to use 1d data matrix for kmeans, eg only Red component of the image? I Googled and searched all over the place and did not find anything.

Answers (1)

Walter Roberson
Walter Roberson on 18 May 2016
Unless you specifically request otherwise in the kmeans call, points are randomly assigned to initial clusters. Then as the kmeans algorithm progresses, points may be moved to some other cluster if they are found to be closer to the other cluster. If they are the same distance then the other cluster is not closer so the point would not be moved.
  2 Comments
Lim
Lim on 19 May 2016
Ah! So, as long as the initial cluster it belongs to is the closest, it will just remain in that cluster until it finds another centroids that is closer to it or until the centroids no longer move, am I understand it right?

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!