5 views (last 30 days)

Show older comments

I have an image with several ROIs(polygon). I need to calculate the middle points of the two sides of the polygon and therefore I need to draw a rectangle inside the polygons and need the corner points' coordinated of each rectangle. Minimum bounding box did not work for my image as I need to fit is inside the ROIs. Could you please help me with this?

I have attached the image.

Image Analyst
on 14 Jul 2021

Why not simply ask regionprops for the angle each is tilted at. Also ask it for the centroid and image if you want.

props = regionprops(binaryImage, 'Orientation', 'Centroid', 'Image');

allAngles = [props.Orientation] % Angles in degrees.

allSlopes = atand(allAngles) % Get slopes from angles.

I'm not sure what you want to do after that, but it seems like your polygons are not really needed.

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

Start Hunting!