Hellou. Could I ask for help finding the center of gravity of the object?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a white object on a black background, so a binary image. The object is irregular and similar to a flattened cylinder. How can we find its center of gravity please?
0 Kommentare
Antworten (1)
Walter Roberson
am 10 Mai 2017
In the case where there are no disconnected pixels, then
info = regionprops( logical(YourImage), 'Centroid');
center_of_gravity = info.Centroid;
In the case where there might be disconnected pixels, then
info = regionprops( 0 + logical(YourImage), 'Centroid');
center_of_gravity = info.Centroid;
the "0 +" is there to turn the image into a label matrix instead of a binary image. If you pass in a binary matrix then normally the centroid of each disconnected region would be calculated.
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!