K-means Clustering
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am doing color based segmentation using kmeans clustering.I am using inbuilt function of matlab(kmeans).My input image has object and background where I need to segment the object. so I am using cluster value as 2.But while doing this, for few images, the background has a cluster index of 2 and object as 1 while in some other images, background has cluster index 1 while object 2. How does K-means clustering decide the index for clusters? If there are to be two clusters, will the background be labeled with number 2 and object with 1 or vice-versa?
0 Commenti
Risposta accettata
Adam
il 4 Gen 2017
Modificato: Adam
il 4 Gen 2017
kmeans chooses seeds by a random process if you do not specify initial locations using the 'start' option. Information on how the algorithm works is in the 'More about' section of the documentation
doc kmeans
There is no way for the algorithm to know what you call 'object' and what you call 'background'. If you give it two start seeds, one in the object and one in the background then these will always remain in this order, but otherwise they can change around with each run of the algorithm unless you fix the random seed, but that would only keep the class centres the same for the same data, not across different data sets obviously.
3 Commenti
Walter Roberson
il 5 Gen 2017
There is no way to force kmeans to use particular indices for particular clusters. You can supply initial cluster centers for kmeans, but you cannot force any particular point to be associated with any particular index: it is entirely possible for any given point to be exchanged back and forth between the clusters a number of times.
You will therefore need to examine the properties of the region to decide whether it is of interest to you.
For example in the sample you show, the area of the second version is much lower: under the assumption that the background is larger than the foreground, the smaller area would be more likely to be the foreground.
Adam
il 5 Gen 2017
I would assume in such a simple circumstance where you have only 2 clusters, one for background and one for your object of interest that it should be relatively easy to find some way to distinguish which group is which. All you need is to know for certain that any one point is in either the background or the object, e.g. the very top left corner - will this ever be part of the object or is the object always entirely enclosed by background?
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!