CurveSimplify documentation#

_images/plot-header.png

CurveSimplify is a collection of polyline simplifying functions.

Each module defines the following functions:

  • min_err() : Minimize the simplification error with given number of vertices.

  • min_num() : Minimize the number of vertices with given simplificationerror.

The following types of errors are supported:

  1. frechet : Fréchet distance

Installation#

CurveSimplify can be installed using pip:

pip install curvesimplify

API reference#

Imai-Iri algorithm#

Simplification algorithm by Imai and Iri [1].

This is a graph-based algorithm, slow but accurate.

References#

[1]

Imai, Hiroshi, and Iri, Masao. “Polygonal approximations of a curve — formulations and algorithms.” Machine Intelligence and Pattern Recognition. Vol. 6. North-Holland, 1988. 71-86.

curvesimplify.imaiiri.min_num(curve, err, err_type='frechet')[source]#

Imai-Iri min-\(\#\) simplification.

Parameters:
curvendarray

A \(p\) by \(n\) array of \(p\) points in an \(n\)-dimensional space.

errdouble

Error threshold.

err_type{‘frechet’}

Error type. Refer to the package docstring.

Returns:
simpndarray

An \(\ell \le p\) by \(n\) array of \(\ell\) points in an \(n\)-dimensional space.

curvesimplify.imaiiri.min_err(curve, ell, err_type='frechet')[source]#

Imai-Iri min-\(\epsilon\) simplification.

Parameters:
curvendarray

A \(p\) by \(n\) array of \(p\) points in an \(n\)-dimensional space.

elldouble

Desired number of vertices of simplification result.

err_type{‘frechet’}

Error type. Refer to the package docstring.

Returns:
simpndarray

An \(p' \le \ell\) by \(n\) array of \(p'\) points in an \(n\)-dimensional space.

errdouble

Simplification error.

Agarwal’s algorithm#

Simplification algorithm by Agarwal et al. [1].

This is a greedy algorithm, fast but relatively inaccurate.

References#

[1]

Agarwal, Pankaj K., et al. “Near-linear time approximation algorithms for curve simplification.” Algorithmica 42 (2005): 203-219.

curvesimplify.agarwal.min_num(curve, err, err_type='frechet')[source]#

Agarwal min-\(\#\) simplification.

Parameters:
curvendarray

A \(p\) by \(n\) array of \(p\) points in an \(n\)-dimensional space.

errdouble

Error threshold.

err_type{‘frechet’}

Error type. Refer to the package docstring.

Returns:
simpndarray

An \(\ell \le p\) by \(n\) array of \(\ell\) points in an \(n\)-dimensional space.

curvesimplify.agarwal.min_err(curve, ell, err_type='frechet')[source]#

Agarwal min-\(\epsilon\) simplification.

Parametric search is evoked on min_num() to find the minimum error satisfying \(\ell\).

Parameters:
curvendarray

A \(p\) by \(n\) array of \(p\) points in an \(n\)-dimensional space.

elldouble

Desired number of vertices of simplification result.

err_type{‘frechet’}

Error type. Refer to the package docstring.

Returns:
simpndarray

An \(p' \le \ell\) by \(n\) array of \(p'\) points in an \(n\)-dimensional space.

errdouble

Simplification error.

Indices and tables#