23

given a convex polgyon and a number N, how do I find the smallest polygon that

  1. contains every point from the original polygon
  2. has exactly N corner points

For example, suppose I have a set of points and compute the convex hull for them (green). Now I want to find the smallest quadrangle that contains all the points (red)

smallest quadrangle enter image description here

It is easy to see that any other polygon with 4 corners would either be bigger or fail to contain all the points. But how do I find this polygon in the general case?


EDIT:

With smallest polygon I mean the the one that covers the smallest area, although I am not sure whether the smallest circumference would give different results.

I added two more example pictures that unfortunately do not seem to work with the 'remove edges' approach in one of the answers


Some background information:

The goal is to accurately determine shapes with image recognition. For example take a foto of a cuboid. All points inside the box in the 2D-photo will be contained in a 6-corner convex polygon. However since real-world shapes do not have perfect corners, and the camera adds some blur, the edges of this polygon will be rounded. See the attached image from the question Getting corners from convex points

blurred corners

Community
  • 1
  • 1
HugoRune
  • 13,157
  • 7
  • 69
  • 144
  • Smallest area and smallest perimeter are in general different, and in general the latter is much more complicated to compute. So, if you have the freedom, aim for minimal area, and see the references I cited. – Joseph O'Rourke Jul 22 '12 at 20:12

2 Answers2

18

You need to define the notion of "smallest" in your question. Whatever your definition, this question has been heavily studied in the computational geometry literature. The key search phrase is minimal enclosing k-gon:

  • Mictchell et al.: "Minimum-Perimeter Enclosing k-gon" 2006 (CiteSeer link)
  • Aggarwal et al.: "Minimum Area Circumscribing Polygons" 1985 (CiteSeer link)
  • O'Rourke et al.: "An optimal algorithm for fnding minimal enclosing triangles" 1986, Algorithmica (ACM link)

The general algorithms are not simple (although algorithms for min area triangles or rectangles are simple). Depending on your goals, you might have to abandon any mathematical notion of "smallest" and head for a heuristic.

Joseph O'Rourke
  • 4,346
  • 16
  • 25
0
While number of edges > N do
  remove the shortest edge by replacing its endpoints 
  with the intersection point of the adjacent edges
Angus Johnson
  • 4,565
  • 2
  • 26
  • 28
  • Elegant and simple! I think my problem was thinking about the problem only in terms of removing points, not edges. To find the definite smallest polygon however, I think it is necessary to always remove the edge that results in the smallest increase in area, which may not be the shortest edge – HugoRune Jul 22 '12 at 17:42
  • -1. Just plain wrong. Just think about examples where a long almost straight side is made up by many short segments. – Johan Lundberg Jul 22 '12 at 17:54
  • I agree, your example certainly shoots down my proposed algorithm. – Angus Johnson Jul 22 '12 at 18:44
  • Although this may not give the optimal solution, it looks like a good approximation, and it has the advantage of being simple to implement. – HugoRune Jan 25 '13 at 22:51
  • Instead of "shortest edge", imagine the polygon is an approximation of a differentiable curve, and estimate the "curvature" along each edge by considering the length of the edge and the angles at each end of the edge. An almost straight side of many edges will have low "curvature". Replace the edge with the highest "curvature" first. – David K Apr 03 '14 at 11:54