Problems with kmeans clustering

4 ビュー (過去 30 日間)
sam  CP
sam CP 2017 年 3 月 31 日
コメント済み: sam CP 2017 年 4 月 3 日
OI have used the following code to segment the attached image. But each iteration on the same image shows different result. How can i solve this by using rng('default'); ?
  2 件のコメント
Adam
Adam 2017 年 3 月 31 日
You should just need to explicitly set the seed (either to 'default' I guess or to any seed of your choice) before each call to kmeans if you want the same result each time.
sam  CP
sam CP 2017 年 3 月 31 日
編集済み: sam CP 2017 年 3 月 31 日
%k-means clustering algorithm
imData = reshape(Y,[],1);
imData = double(imData);
[IDX nn] = kmeans(imData,'default');
imIDX = reshape(IDX,size(Y));
figure, imshow(imIDX,[]),title('Image after applying k-means Clustering Algorithm');
Where can i apply the rng('default'); ?

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

採用された回答

the cyclist
the cyclist 2017 年 3 月 31 日
編集済み: the cyclist 2017 年 3 月 31 日
Looking at your code, you should be able to put the line
rng('default')
literally anywhere before the call to kmeans, because you do not call any other random number functions. But the safest bet might be to call it in the line just before the call to kmeans, in case you do something differently later.
But, also, I don't think you put 'default' in the actual kmeans call. So it should be like this ...
%k-means clustering algorithm
imData = reshape(Y,[],1);
imData = double(imData);
rng('default')
[IDX nn] = kmeans(imData);
imIDX = reshape(IDX,size(Y));
figure, imshow(imIDX,[]),title('Image after applying k-means Clustering Algorithm');
  10 件のコメント
Image Analyst
Image Analyst 2017 年 3 月 31 日
Yeah, but let's put "works" in quotation marks because kmeans() is not a good method for finding brain tumors. Imagine what your algorithm would find for class 4 if there were no tumor present, or a very small one. Yeah, see what I mean?
sam  CP
sam CP 2017 年 4 月 3 日
I have already found that the kmeans clustering method can't be detect the tumor when it is very small.

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by