kmeans clustering on n*3 matrix

4 ビュー (過去 30 日間)
taylor hietpas
taylor hietpas 2018 年 7 月 9 日
回答済み: Image Analyst 2018 年 7 月 10 日
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?

回答 (2 件)

dpb
dpb 2018 年 7 月 9 日
>> 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 件のコメント
dpb
dpb 2018 年 7 月 9 日
編集済み: dpb 2018 年 7 月 10 日
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 2018 年 7 月 10 日
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!

サインインしてコメントする。


Image Analyst
Image Analyst 2018 年 7 月 10 日
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.

カテゴリ

Help Center および File ExchangeCluster Analysis and Anomaly Detection についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by