Hellou. Could I ask for help finding the center of gravity of the object?
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Walter Roberson
2017 年 5 月 10 日
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!