How to plot the centroids of kmeans in an image?

3 ビュー (過去 30 日間)
chang zhao
chang zhao 2019 年 7 月 24 日
回答済み: Yogesh Khurana 2019 年 7 月 29 日
I have a binary images (black and white) to cluster using
[idx, C] = kmeans(img, 3)
and now i want to plot the centroid in this image ,may i ask how to draw the centroids of kmeans?
should i expand the image into a column?

回答 (1 件)

Yogesh Khurana
Yogesh Khurana 2019 年 7 月 29 日
kmeans returns a numeric matrix containing Centroid location. Once you have locations you can plot these locations using plot function. I am assuming you want to plot these centroids on the same image as background. For that you can use MATLAB’s uistack function that reorders visual stacking of UI components. You can refer to following function’s documentations for more information:
Hope this helps!

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by