centroid of an image

Please, I need help with Matlab code to center the upper half of a silhouette image with respect to its horizontal centroid(ie find the centroid of an image ), after which my output will still be in an image format. Thanks in anticipation.

 Accepted Answer

Threshold the image into black and white, and then call regionprops on the black and white image to get the centroid property.
Note: if the black part is your information and the white part is background, then call regionprops on the logical negation of your black and white image,
regionprops(~BW,'centroid') %or something similar

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!