kmeans clustering on n*3 matrix

4 visualizzazioni (ultimi 30 giorni)
taylor hietpas
taylor hietpas il 9 Lug 2018
Risposto: Image Analyst il 10 Lug 2018
I am evaluating an n*3 matrix using kmeans. The idx result which I get is only n*1. What does this mean? Is the algorithm only evaluating each column as separate observations?

Risposte (2)

dpb
dpb il 9 Lug 2018
>> help kmeans
kmeans K-means clustering.
IDX = kmeans(X, K) partitions the points in the N-by-P data matrix X
into K clusters. This partition minimizes the sum, over all clusters, of
the within-cluster sums of point-to-cluster-centroid distances. Rows of X
correspond to points, columns correspond to variables. ...
kmeans returns an N-by-1 vector IDX containing the cluster indices of each point.
...
Each row is a joint observation; how do you want the input array to be interpreted?
  3 Commenti
dpb
dpb il 9 Lug 2018
Modificato: dpb il 10 Lug 2018
Each row is then a RGB triplet, I gather? KMEANS will simply try to separate those based on a "distance" measure into non-overlapping groups based on solely that distance measure from the group centroid given an a priori number of groups.
It uses the three values to compute a single measure; there's no sense of 3D left for it to operate on.
I'm not enough of an image-processing type to have a more suitable algorithm otomh but I don't think this is what you're looking for...it should isolate areas of roughly the same hue/intensity, however, but it will do those globally throughout the image.
taylor hietpas
taylor hietpas il 10 Lug 2018
well that is one variation i am playing with. I also tried another method of formatting the pixel array into the appropriate dimensions for the clustering. still I get the result of an n*1 index vector. now I am trying to take that info and turn it into a mask relative to the original matrix. i remain somewhat confused but I am still trying. thanks for your insight!

Accedi per commentare.


Image Analyst
Image Analyst il 10 Lug 2018
The output is the classified result. It will be a number 1, 2, or 3 depending on whether it thinks that row belongs to class 1, class 2, or class 3.
k-means is a lousy way to classify RGB images. Nonetheless, I attach a demo so you can see for yourself. Discriminant analysis is better and I also attach a demo for that.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by