Hellou. Could I ask for help finding the center of gravity of the object?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Walter Roberson
il 10 Mag 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.
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!