How to find object perimeter/bounding box perimeter?

Can some one please provide me a code that finds a ratio between object perimeter and bounding box perimeter:
ratio = object perimeter / bounding box perimeter

2 Comments

What data you have?
I have five blobs in a binary image.
Now i want to divide the perimeter of blobs by their corresponding bounding box perimeter.

Sign in to comment.

 Accepted Answer

5 Comments

Sir, is it possible to get perimeter of all bounding box??
The link you have shared, that is for circularity. But how i could find all the perimeter of all blobs in a binary image?
And how to divide the perimeter of blobs by their corresponding bounding box perimeter?
Use regionprops to get the bounding boxes, then add the widths and heights
props = regionprops(labeledImage, 'BoundingBox');
bb = [props.BoundingBox];
widths = bb(3:4:end);
heights = bb(4:4:end);
bbPerimeters = 2 * (widths + heights);
bbPerimeters is the perimeter of all the boxes. Each index is the perimeter of one of the blob's bounding boxes.
Thank you very much, Sir.
That's exactly the method which was i looked for.
Thank you again.
the widths = X max - X Min then widths= bb(3:4:end)- bb(1:4:end); NO ?
No. Why do you think bb(3) is the x max value? You can tell whomever told you that, that they're wrong because you and I can both read regionprops and see that "the vector [ul_corner width], ul_corner specifies the upper-left corner of the bounding box in the form [x y z ...]. width specifies the width of the bounding box along each dimension in the form [x_width y_width ...]"
So bb is [xLeft, yTop, xWidth, yHeight].

Sign in to comment.

More Answers (0)

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!