deepof.arena_utils.simplify_polygon

deepof.arena_utils.simplify_polygon(polygon: list, n_points: int | None = None, relative_tolerance: float = 0.05, preserve_topology: bool = False)

Simplify a polygon using shapely’s RDP simplify, and if n_points is given, return exactly n_points denoised vertices whose sides are aligned with the dominant sides of the (noisy) input polygon.

Strategy for n_points:
  1. Pick exactly n_points “corners” (fixed-number Douglas–Peucker style).

  2. For each side between corners, fit a best-fit line (TLS/PCA) to its points.

  3. Export vertex points for best line segment fits.