Skip to main content
Help us improve Python packaging – donate today!

Python implementation of "Elliptic Fourier Features of a Closed Contour"

Project Description

PyEFD Documentation Status

An Python/NumPy implementation of a method for approximating a contour with a Fourier series, as described in [1].


$ pip install pyefd


Given a closed contour of a shape, generated by e.g. scikit-image or OpenCV, this package can fit a Fourier series approximating the shape of the contour:

from pyefd import elliptic_fourier_descriptors
coeffs = elliptic_fourier_descriptors(contour, order=10)

The coefficients returned are the a_n, b_n, c_n and d_n of the following Fourier series representation of the shape.

The coefficients returned are by default normalized so that they are rotation and size-invariant. This can be overridden by calling:

from pyefd import elliptic_fourier_descriptors
coeffs = elliptic_fourier_descriptors(contour, order=10, normalize=False)

Normalization can also be done afterwards:

from pyefd import normalize_efd
coeffs = normalize_efd(coeffs)

To use these as features, one can write a small wrapper function:

def efd_feature(contour):
    coeffs = elliptic_fourier_descriptors(contour, order=10, normalize=True)
    return coeffs.flatten()[3:]

If the coefficients are normalized, then coeffs[0, 0] = 1.0, coeffs[0, 1] = 0.0 and coeffs[0, 2] = 0.0, so they can be disregarded when using the elliptic Fourier descriptors as features.

See [1] for more technical details.


Run tests with:

$ python test

or with Pytest:

$ py.test

The tests includes a single image from the MNIST dataset of handwritten digits ([2]) as a contour to use for testing.


See ReadTheDocs.

v1.0 (2016-04-19)

  • Deemed stable enough for version 1.0 release
  • Created documentation.

v0.1.2 (2016-02-29)

  • Testing with pytest instead of nosetests.
  • Added Coveralls use.

v0.1.1 (2016-02-17)

  • Fixed MANIFEST
  • Added LICENSE file that was missing.

v0.1.0 (2016-02-09)

  • Initial release

Release history Release notifications

This version
History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pyefd-1.0-py2.py3-none-any.whl (7.5 kB) Copy SHA256 hash SHA256 Wheel 2.7 Apr 19, 2016
pyefd-1.0.tar.gz (7.6 kB) Copy SHA256 hash SHA256 Source None Apr 19, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page