MATLAB: Image processing – calculate center mass and its initial moment

center massimage processingImage Processing Toolboximage segmentation

I have video which contains a 1000 frames, in spesific frame I did segmentation and the image become white and black as it attched. how I can find the center mass for this segmented white part.

Best Answer

Call regionprops(binaryImage, 'Centroid')
binaryImage = bwareafilt(binaryImage, 1); % Take largest only.
props = regionprops(binaryImage, 'Centroid') % Find centroid.
xCentroid = props.Centroid(1);
yCentroid = props.Centroid(2);
See the Image Segmentation Tutorial in my file Exchange for a full demo: