42 views (last 30 days)

Image Analyst
on 17 Sep 2013

Simon
on 17 Sep 2013

As far as I see it is not obvious what the smallest rectangle that still contains the polygon is. One way is

- search for the longest side of the polygon
- Take this side as the base of the new rectangle (has two points in common with the polygon)
- Get the distance of the furthermost remaining point
- Construct the opposite edge of the rectangle, crossing this point
- Construct the remaining two connecting edges perpendicular to the first edge

This will give you a rectangle with small size (I don't know if it is the minimum size!). And it is all pure 2d-geometry, easy to implement, nothing fancy

Image Analyst
on 17 Sep 2013

I haven't used John's function for rectangle but I imagine it would give the coordinates of the corners. If there are 5 instead of 4 it could be because the last point is the same as the first point to "close off" the rectangle instead of it being a "U" shape.

Imagine that you put a box around your points. Now, as you rotate the box around your points, the sides of the box will have to lengthen or shorten to still contain your points. With one of those shapes of boxes, the area will be a minimum. That is the box he returns to you.

Simon
on 17 Sep 2013

Hi!

You have your polygon coordinates in (x/y) pairs? Take their min/max values and cut from the video frame the rectangle R(xmin:xmax, ymin:ymax).

Maybe you post your code, then it's easier to help.

Simon
on 17 Sep 2013

Hi!

You have your variable "pos". Now you get the minimum and maximum x and y values. This are the coordinates of your rectangle, it contains all polygons.

Image Analyst
on 17 Sep 2013

Opportunities for recent engineering grads.

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

Start Hunting!
## 0 Comments

Sign in to comment.