Class EllipticFourierDesc

java.lang.Object
micycle.pgs.commons.EllipticFourierDesc

public class EllipticFourierDesc extends Object
Implements Elliptic Fourier Descriptors (EFD).

The EFD provides a normalized set of coefficients that are rotation, translation and scale invariant. The very first coefficient relates to the centroid of the input shape before the EFD is computed and can be ignored; the second FD coefficient relates to a circle circumscribed about the centroid before the EFD computation. After the EFD computation the second EFD is always 2 and can be ignored. That leaves the remaining EFD coefficients for use in comparing shapes.

  • Constructor Summary

    Constructors
    Constructor
    Description
    EllipticFourierDesc(org.locationtech.jts.geom.LinearRing ring)
    Constructs a descriptor object for a given polygon and computes #vertices/2 Elliptical Fourier Descriptors for it.
    EllipticFourierDesc(org.locationtech.jts.geom.LinearRing ring, int n)
    Constructs a descriptor object for a given polygon and computes the Elliptical Fourier Descriptors for it.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    computeEFDDistance(double[] efd1, double[] efd2)
    Computes pairwise euclidean distance between two descriptors (of equal length).
    org.locationtech.jts.geom.Coordinate[]
    Returns the polygon computed using all of this instance's EFD coefficients.
    org.locationtech.jts.geom.Coordinate[]
    Creates the polygon corresponding to the nth harmonic.
    double[]
    Returns the elliptic fourier descriptors, which are computed upon initialisation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EllipticFourierDesc

      public EllipticFourierDesc(org.locationtech.jts.geom.LinearRing ring, int n)
      Constructs a descriptor object for a given polygon and computes the Elliptical Fourier Descriptors for it.
      Parameters:
      coords - A two-dimensional array representing the vertices of the polygon. Each row contains the x and y coordinates of a vertex.
      n - The number of Fourier descriptors to compute. This is also the number of harmonics used in the Fourier series. >=2.
    • EllipticFourierDesc

      public EllipticFourierDesc(org.locationtech.jts.geom.LinearRing ring)
      Constructs a descriptor object for a given polygon and computes #vertices/2 Elliptical Fourier Descriptors for it.
      Parameters:
      x - the x coordinates of the contour
      y - the y coordinates of the contour
  • Method Details

    • getEFD

      public double[] getEFD()
      Returns the elliptic fourier descriptors, which are computed upon initialisation.

      The very first coefficient relates to the centroid of the input shape before the EFD is computed and can be ignored; the second FD coefficient relates to a circle circumscribed about the centroid before the EFD computation -- after the EFD computation this second EFD is always 2 and can be ignored.

      Returns:
      list of coefficients/harmonics
    • createPolygon

      public org.locationtech.jts.geom.Coordinate[] createPolygon()
      Returns the polygon computed using all of this instance's EFD coefficients.
      Returns:
      an array of (x,y) pairs that is the same length as the input polygon
    • createPolygon

      public org.locationtech.jts.geom.Coordinate[] createPolygon(int n)
      Creates the polygon corresponding to the nth harmonic.
      Parameters:
      n - >= 2.
      Returns:
      an array of coordinates that has the same length as the input polygon vertices, and forms a closed ring
    • computeEFDDistance

      public static double computeEFDDistance(double[] efd1, double[] efd2)
      Computes pairwise euclidean distance between two descriptors (of equal length).