finding number of centroids of a binary image

7 vues (au cours des 30 derniers jours)
Itamar Malageac
Itamar Malageac le 25 Nov 2021
Hello,
I have an image of separated shapes and Im trying to get thier centroids.
The image is binary-like image means it fills with zeros and any shape is fills with numbers.
Say there are 10 shapes in the image, every shape has its number from 1 to 10 and that is the value in the image.. i would like to get 10 centroids of the shapes.

Réponse acceptée

Image Analyst
Image Analyst le 25 Nov 2021
Try my Image Segmentation Tutorial. It gives a well commented demo to find the centroids and other things.
In short,
binaryImage = grayImage > 0;
props = regionprops(binaryImage, 'Centroid')
centroidsxy = vertcat(props.Centroid)

Plus de réponses (1)

KSSV
KSSV le 25 Nov 2021
REad about regionprops. You can also try kmeans. Read about it.
  1 commentaire
Itamar Malageac
Itamar Malageac le 25 Nov 2021
thank you!
i just found it and it works

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by