MATLAB: Centroid of convex hull

bwconvhullcentroidsconvex hullImage Processing Toolbox

hi, i want to find de centroid of convex hull, how i can do it in matlab? I formed the convex hull with n-dimensional points. To find the convex hull i use convhull and convhulln thanks for your help

Best Answer

You need to get a binary image first. If you just have x,y coordinates, like you used convhull, then you need to call poly2mask(). If you have an image of non-convex objects, then you need to call bwconvhull() and it will give you an image of all objects' convex hulls. Then simply call regionprops asking for the centroid.
measurements = regionprops(binaryImage, 'Centroid');
It's a structure array. Each element of measurements is a structure with fields that represent the measurements you asked it to make, like Centroid, area, whatever.