Crate efd[][src]

Expand description

This crate implements Elliptical Fourier Descriptor (EFD) curve fitting by using ndarray to handle the 2D arrays.

Reference: Kuhl, FP and Giardina, CR (1982). Elliptic Fourier features of a closed contour. Computer graphics and image processing, 18(3), 236-258.

The following is an example. The contours are always Nx2 array in the functions.

use std::f64::consts::TAU;
use ndarray::{Array1, Axis, stack};
use efd::{efd_fitting, ElementWiseOpt};

fn main() {
    const N: usize = 10;
    let circle = stack!(Axis(1),
                        Array1::linspace(0., TAU, N).cos(),
                        Array1::linspace(0., TAU, N).sin());
    assert_eq!(circle.shape(), &[10, 2]);
    let new_curve = efd_fitting(&circle, 20, None);
    assert_eq!(new_curve.shape(), &[20, 2]);
}

Arrays have “owned” and “view” two data types, all functions are compatible.

Traits

Implement several element-wise operations for ndarray::ArrayBases.

Functions

Compute the Elliptical Fourier Descriptors for a polygon.

Calculate the n-th discrete difference along the given axis. Same as NumPy version.

Curve fitting using Elliptical Fourier Descriptor.

Compute the total Fourier power and find the minimum number of harmonics required to exceed the threshold fraction of the total power.

Perform an inverse fourier transform to convert the coefficients back into spatial coordinates.

Compute the c, d coefficients, used as the locus when calling inverse_transform.

Normalize the Elliptical Fourier Descriptor coefficients for a polygon.

Returns the maximum number of harmonics that can be computed for a given contour, the Nyquist Frequency.

Rotates a contour about a point by a given amount expressed in degrees.