How can I find the centroids of closely seperated object?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Bipul Biswas
am 23 Aug. 2021
Kommentiert: Bipul Biswas
am 23 Aug. 2021
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/719159/image.png)
In the left pannel, I have four obejct, they are close but separated. I am using the " regionprops( image ,'Area','BoundingBox', 'Centroid') but in return I am getting only one centriods. I need each object's centroids. Can you please help me with it?
2 Kommentare
Akzeptierte Antwort
DGM
am 23 Aug. 2021
Bearbeitet: DGM
am 23 Aug. 2021
I'm going to go out on a limb here and guess that the image you're feeding to regionprops() is a numeric image instead of a logical image. If that's the case, it will assume that it's a label array (as from bwlabel()). From that assumption, it interprets all blobs as having the same label (label 1), treating them all as one object.
inpict = imread('4dot.png');
% if the image is numeric
inpict = im2double(inpict);
S = regionprops(inpict,'centroid');
C = vertcat(S.Centroid)
% if the image is logical
inpict = inpict>0.5;
S = regionprops(inpict,'centroid');
C = vertcat(S.Centroid)
4 Kommentare
DGM
am 23 Aug. 2021
Given that OP is dividing the objects into two regions, I was under the impression that the half-object centroids was more important than the centroid of each round object.
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!