MATLAB: How to find the area of each bounding box of an image

binary imageboundingboxmachine vision

How do you calculate area of bounding box?

Best Answer

BB = vertcat(compBinaryFeat.BoundingBox);
BBarea = BB(:,3).*BB(:,4);
Caution: the bounding box of the center object includes the bounding boxes of two smaller objects. You should think about whether you really want the area of the bounding boxes, or if instead you want the areas of the objects -- which you can get by requesting the Area property.
Also I suggest you look at bwareafilt() unless you are using an older MATLAB.
Related Question