GithubHelp home page GithubHelp logo

polyprox's Introduction

Polygonal Curve approximation

https://travis-ci.org/geissdoerfer/polyprox.svg?branch=master

Fast implementation of solutions to the min-num and min-e problems of digital curve approximation.

Both approximate a planar curve given as a series of points by a subset of these points with the minimum maximum euclidean distance between the original curve and the linearly interpolated approximation. This distance is calculated according to the tolerance zone criterion, described in Alexander Kolesnikov's thesis

Both algorithms use the Ramer-Douglas-Peucker (RDP) algorithm as a subroutine. This algorithm is fast and usually ends up with good approximations, but does not guarantee optimality of the solution.

The min-e problem takes the length of the subset, i.e. the number of approximating points and calculates the solution with the minimum maximum error. Note that, due to the nature of the algorithm, the resulting subset length can differ slightly from the required number of points. The min-num problem takes an upper error bound and approximates the curve with the minimum length subset meeting this error criterion.

The algorithms are implemented in C and accessible by a pythonic interface. The min-num implementation offers similar functionality as the RDP implementations by sebleier and fhirschmann, but can be orders of magnitudes faster and more suitable for large curves. The present implementation uses a different error measure than these implementations (tolerance zone vs infinite beam).

Installation

pip install polyprox

Usage

import numpy
import polyprox
G = numpy.array([[0, 0], [0.9, 0], [1.1, 1.3], [2.5, 1.0], [2.2, 2.4]])
polyprox.min_e(G, m=2)
polyprox.min_num(G, epsilon=0.75)

Credits

Kun Zhao: initial python implementation

License

CSIRO Open Source Software License Agreement (variation of the BSD/MIT License)

References

H. Imai and M. Iri. 1988. "Polygonal approximations of a curve - formulations and algorithms." In: Computational Morphology: A Computational Geometric Approach to the Analysis of Form: 71–86.
W. S. Chan and F. Chin. 1996. "Approximation of polygonal curves with minimum number of line segments or minimum error." In: International Journal of Computational Geometry & Applications, 6 (01): 59–77
Douglas, David H, and Thomas K Peucker. 1973. “Algorithms for the Reduction of the Number of Points Required to Represent a Digitized Line or Its Caricature.” In: Cartographica: The International Journal for Geographic Information and Geovisualization 10 (2): 112–122.

polyprox's People

Contributors

geissdoerfer avatar marcoleewow avatar

Stargazers

Lavender Lee avatar  avatar Osman Tunçelli avatar Alex Hartloper avatar  avatar Ali Athar avatar  avatar Kirill Morozov avatar Dmitri avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.