How to plot the centroids of kmeans in an image?

1 view (last 30 days)
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?

Answers (1)

Yogesh Khurana
Yogesh Khurana on 29 Jul 2019
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!

Tags

Community Treasure Hunt

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

Start Hunting!