pub struct Efd<D: EfdDim> { /* private fields */ }Expand description
Elliptical Fourier Descriptor coefficients. Provide transformation between discrete points and coefficients.
Transformation
The transformation of normalized coefficients.
Implements Kuhl and Giardina method of normalizing the coefficients An, Bn, Cn, Dn. Performs 3 separate normalizations. First, it makes the data location invariant by re-scaling the data to a common origin. Secondly, the data is rotated with respect to the major axis. Thirdly, the coefficients are normalized with regard to the absolute value of A₁.
Please see Transform for more information.
Implementations§
source§impl<D: EfdDim> Efd<D>
impl<D: EfdDim> Efd<D>
sourcepub fn try_from_coeffs(coeffs: Array2<f64>) -> Result<Self, EfdError<D>>
pub fn try_from_coeffs(coeffs: Array2<f64>) -> Result<Self, EfdError<D>>
Create object from a nx4 array with boundary check.
sourcepub fn gate<C, T>(curve: C, threshold: T) -> Option<usize>where
C: Curve<Coord<D>>,
Option<f64>: From<T>,
pub fn gate<C, T>(curve: C, threshold: T) -> Option<usize>where C: Curve<Coord<D>>, Option<f64>: From<T>,
Apply Nyquist Frequency on Fourier power analysis with a custom threshold value (default to 99.99%).
This method returns the minimum harmonic number to keep the shape features.
The threshold must in [0, 1). This function returns None if the curve
length is less than 1.
let harmonic = efd::Efd2::gate(curve, None).unwrap();sourcepub fn from_curve<C>(curve: C) -> Option<Self>where
C: Curve<Coord<D>>,
pub fn from_curve<C>(curve: C) -> Option<Self>where C: Curve<Coord<D>>,
Calculate EFD coefficients from an existing discrete points.
The curve must be closed. (first == last)
Return none if the curve length is less than 1.
sourcepub fn from_curve_gate<C, T>(curve: C, threshold: T) -> Option<Self>where
C: Curve<Coord<D>>,
Option<f64>: From<T>,
pub fn from_curve_gate<C, T>(curve: C, threshold: T) -> Option<Self>where C: Curve<Coord<D>>, Option<f64>: From<T>,
Calculate EFD coefficients from an existing discrete points and Fourier power gate.
The curve must be closed. (first == last)
Return none if the curve length is less than 1.
sourcepub fn from_curve_harmonic<C, H>(curve: C, harmonic: H) -> Option<Self>where
C: Curve<Coord<D>>,
Option<usize>: From<H>,
pub fn from_curve_harmonic<C, H>(curve: C, harmonic: H) -> Option<Self>where C: Curve<Coord<D>>, Option<usize>: From<H>,
Calculate EFD coefficients from a series of existing discrete points.
The curve must be closed. (first == last)
Return none if harmonic number is zero or the curve is less than two points.
If the harmonic number is not given, it will be calculated with
Self::gate() function.
See also [closed_curve].
sourcepub fn with_trans(self, trans: Transform<D::Trans>) -> Self
pub fn with_trans(self, trans: Transform<D::Trans>) -> Self
A builder method for changing transform type.
sourcepub fn into_inner(self) -> Array2<f64>
pub fn into_inner(self) -> Array2<f64>
Consume self and return a raw array of the coefficients.
sourcepub fn coeffs(&self) -> ArrayView2<'_, f64>
pub fn coeffs(&self) -> ArrayView2<'_, f64>
Get the array view of the coefficients.
sourcepub fn as_trans_mut(&mut self) -> &mut Transform<D::Trans>
pub fn as_trans_mut(&mut self) -> &mut Transform<D::Trans>
Get the mutable reference of transform type.
sourcepub fn square_err(&self, rhs: &Self) -> f64
pub fn square_err(&self, rhs: &Self) -> f64
sourcepub fn lp_norm(&self, rhs: &Self, p: i32) -> f64
pub fn lp_norm(&self, rhs: &Self, p: i32) -> f64
Lp norm error, slower than Self::l1_norm() and Self::l2_norm().
Panics
When the harmonic number is different.
sourcepub fn reverse(&mut self) -> &mut Self
pub fn reverse(&mut self) -> &mut Self
Reverse the order of described curve then return a mutable reference.
sourcepub fn reversed(self) -> Self
pub fn reversed(self) -> Self
Consume and return a reversed version of the coefficients. This method can avoid mutable require.
Please clone the object if you want to do self-comparison.
sourcepub fn generate_norm(&self, n: usize) -> Vec<Coord<D>>
pub fn generate_norm(&self, n: usize) -> Vec<Coord<D>>
Generate the normalized curve without transformation.
The number of the points n must larger than 3.
Trait Implementations§
Auto Trait Implementations§
impl<D> RefUnwindSafe for Efd<D>where D: RefUnwindSafe, <D as EfdDim>::Trans: RefUnwindSafe,
impl<D> Send for Efd<D>where D: Send, <D as EfdDim>::Trans: Send,
impl<D> Sync for Efd<D>where D: Sync, <D as EfdDim>::Trans: Sync,
impl<D> Unpin for Efd<D>where D: Unpin, <D as EfdDim>::Trans: Unpin,
impl<D> UnwindSafe for Efd<D>where D: UnwindSafe, <D as EfdDim>::Trans: UnwindSafe,
Blanket Implementations§
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.