MATLAB: How center of mass of an image is calculated

center of massImage Processing Toolbox

sir, do you have any matlab code for finding center of mass of an image.

Best Answer

Probably the easiest is to use regionprops(). Something like (untested)
binaryImage = true(size(grayImage));
labeledImage = bwlabel(binaryImage);
measurements = regionprops(labeledImage, grayImage, 'WeightedCentroid');
centerOfMass = measurements.WeightedCentroid;