Class EllipticFourierDesc
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
ConstructorsConstructorDescriptionEllipticFourierDesc
(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 TypeMethodDescriptionstatic 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[]
createPolygon
(int n) Creates the polygon corresponding to the nth harmonic.double[]
getEFD()
Returns the elliptic fourier descriptors, which are computed upon initialisation.
-
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 contoury
- 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).
-