How to draw bounding box around white area in binary image

this test image Promblem I want draw bounding box and know angle of image 4 angle

 Accepted Answer

Use regionprops() to get the bounding box.
I don't know what "angle of image 4 angle" is.

7 Comments

Angle of image top left measured from the center
please write code use boundingbox
Angle? As in the arctan of the ratio between the height and width?
Try this:
[labeledImage, numRegions] = bwlabel(mask);
props = regionprops(labeledImage, 'BoundingBox');
hold on;
% Plot the bounding box around each region.
for k = 1 : numRegions
thisBB = props(k).BoundingBox;
rectangle('Position', thisBB, 'Color', 'r');
end
Thank you I start learn in matlab in 2 month
Yes Angle as between the height and width

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!