How can I find the center of mass
23 views (last 30 days)
Show older comments
How can I find center of mass of a frame? I need to find the speed of first and second frame with using center of mass and time. These are frames: 


0 Comments
Answers (1)
Image Analyst
on 15 Mar 2020
Edited: Image Analyst
on 15 Mar 2020
Use regionprops():
props = regionprops(mask, grayImage, 'WeightedCentroid');
xCOM = props.WeightedCentroid(1)
yCOM = props.WeightedCentroid(2)
If you want the unweighted centroid (unweighted by the gray scale image's values), use 'Centroid' instead of 'WeightedCentroid'.
To get the speed, take the delta x and y and use sqrt() to find the distance between and then divide by the time difference between the frames
distance = sqrt(x2-x1)^2 + (y2-y1)^2);
speed = distance / deltaTime;
3 Comments
Image Analyst
on 16 Mar 2020
Did it throw an error? regionprops() is in the Image Processing Toolbox and is one of the main functions of that toolbox. Type
>> ver
to see if you have that toolbox.
See Also
Categories
Find more on Image Segmentation and Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!