MATLAB Answers

0

How to plot the centroids of kmeans in an image?

Asked by chang zhao on 24 Jul 2019
Latest activity Answered by Yogesh Khurana on 29 Jul 2019
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?

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by 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!

  0 Comments

Sign in to comment.