MATLAB: How to find the centre of gravity of an image

image processing

I tried regionprops but it is giving out more than one centroid and I need the centre of gravity of the entire image. Thank you.

Best Answer

You need to have the binary image be the entire image. Just do something like this (untested):
binaryImage = true(size(grayImage));
measurements = regionprops(binaryImage, grayImage, 'WeightedCentroid');
cog = measurements(1).WeightedCentroid;