This class represents elliptic Fourier descriptors. See Ch. 26 of [1] for additional details including invariance calculations.
[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction Using Java, 2nd ed, Springer (2016).
- Version:
- 2022/10/24
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for cloning Fourier descriptors.FourierDescriptor
(Complex[] G) Constructor using the default scale (1.0).FourierDescriptor
(Complex[] G, double scale) Constructor using a specific scale. -
Method Summary
Modifier and TypeMethodDescriptiondouble
Returns a L2-type distance between this and anotherFourierDescriptor
instance comparing the real and imaginary parts of all coefficient pairs.double
distanceComplex
(FourierDescriptor fd2, int p) Returns a L2-type distance between this and anotherFourierDescriptor
instance comparing the real and imaginary parts of a limited range of (low-frequency) coefficient pairs.double
Returns a L2-type distance between this and anotherFourierDescriptor
instance comparing the magnitudes of all coefficient pairs.double
distanceMagnitude
(FourierDescriptor fd2, int p) Returns a L2-type distance between this and anotherFourierDescriptor
instance comparing the magnitudes of a limited range of (low-frequency) coefficient pairs.getCoefficient
(int m) Returns the complex-valued DFT coefficient with the specified frequency index m.int
getCoefficientIndex
(int m) Returns the coefficient array index for the specified frequency index, which may be positive or negative.Complex[]
getCoefficientPair
(int m) Returns the Fourier coefficient pair (G[-m], G[+m]) as aComplex
valued array.Complex[]
Returns the array G = {G[0], ..., G[M-1]} of complex-valued DFT coefficients.getEllipse
(int m) Returns the ellipse associated with a single Fourier coefficient pair (G[-m], G[+m]) as a (AWT)Shape
object.double[]
getEllipseParameters
(int m) Returns the parameters of the geometric ellipse associated with a single Fourier coefficient pair (G[-m], G[+m]).int
getMp()
Returns the number of Fourier coefficient pairs for this descriptor.double
getScale()
Returns the scale of this Fourier descriptor, that is, the factor required to scale it to its original (sample) size.Complex[]
getShapeFull
(int n) Reconstructs the associated 2D shape (closed contour) with N sample points, using all of the Fourier descriptor's coefficient pairs.Complex[]
getShapePair
(int n, int m) Reconstructs the associated 2D shape (closed contour) with N sample points, using only a single coefficient pairs.Complex[]
getShapePartial
(int n, int p) Reconstructs the associated 2D shape (closed contour) with N sample points, using only a subset of the Fourier descriptor's coefficient pairs.getShapePointFull
(double t) Reconstructs a single space point of the associated shape (closed contour) at the fractional path position t ∈ [0,1], using all of the Fourier descriptor's coefficient pairs.getShapePointPair
(int m, double t) Returns the spatial point reconstructed from a single DFT coefficient pair G[-m], G[+m] at position t ∈ [0,1].getShapePointPartial
(int p, double t) Reconstructs a single space point of the associated shape (closed contour) at the fractional path position t ∈ [0,1], using only a subset of the Fourier descriptor's coefficient pairs.Makes this Fourier descriptor invariant to scale, start-point and rotation.Returns a new rotation invariant Fourier descriptor by applying complex rotation to all coefficients (except coefficient 0).Returns a new scale invariant Fourier descriptor by normalizing the L2 norm of the sub-vector {G[-mp], ..., G[-1], G[1], ..., G[mp]}.Returns a pair of start-point normalized Fourier descriptors.Returns a new translation invariant Fourier descriptor by setting coefficient 0 to zero.int
size()
Returns the size (length) of this Fourier descriptor's array of DFT coefficients G.static Complex[]
toComplexArray
(Pnt2d[] points) static Path2D
toString()
-
Field Details
-
MinReconstructionSamples
- See Also:
-
-
Constructor Details
-
FourierDescriptor
Constructor using the default scale (1.0).- Parameters:
G
- a complex-valued DFT spectrum
-
FourierDescriptor
Constructor using a specific scale.- Parameters:
G
- a complex-valued DFT spectrumscale
- the reconstruction scale
-
FourierDescriptor
Constructor for cloning Fourier descriptors.- Parameters:
fd
- an existing instance
-
-
Method Details
-
size
Returns the size (length) of this Fourier descriptor's array of DFT coefficients G. The resulting value is always odd.- Returns:
- the size of the DFT coefficient array (M)
-
getScale
Returns the scale of this Fourier descriptor, that is, the factor required to scale it to its original (sample) size. The scale factor is changed in the process of making descriptors scale-invariant.- Returns:
- the scale factor
-
getMp
Returns the number of Fourier coefficient pairs for this descriptor. The result is (M-1)/2, M being the size of the DFT coefficient array G.- Returns:
- the number of Fourier coefficient pairs
-
getCoefficients
Returns the array G = {G[0], ..., G[M-1]} of complex-valued DFT coefficients.- Returns:
- the array of DFT coefficients
-
getCoefficient
Returns the complex-valued DFT coefficient with the specified frequency index m. The returned coefficient is G[k] with k = (m mod G.length). Unique coefficients are returned for m = 0, ..., M-1, where M is the size of the DFT coefficient array, or m = -mp, ..., +mp where mp is the number of coefficient pairs. For example, given a Fourier descriptor with a 9-element spectrum,
k = 0 1 2 3 4 5 6 7 8 G[k] = a b c d e f g h i
the following values are returned:
getCoefficient(0) → G[0] = a getCoefficient(1) → G[1] = b ... getCoefficient(4) → G[4] = e getCoefficient(-1) → G[8] = i ... getCoefficient(-4) → G[5] = f getCoefficient(-5) → G[4] = e ...
- Parameters:
m
- frequency index (positive or negative)- Returns:
- the associated DFT coefficient
- See Also:
-
getCoefficientPair
Returns the Fourier coefficient pair (G[-m], G[+m]) as aComplex
valued array.- Parameters:
m
- frequency index- Returns:
- the DFT coefficient pair
-
getCoefficientIndex
Returns the coefficient array index for the specified frequency index, which may be positive or negative.- Parameters:
m
- frequency index (positive or negative)- Returns:
- the coefficient array index
- See Also:
-
makeInvariant
Makes this Fourier descriptor invariant to scale, start-point and rotation. The descriptors center position (coefficient 0) is preserved. Performs the following normalization steps in sequence:
- scale invariance,
- start-point invariance,
- rotation invariance.
Multiple candidate descriptors are returned, since start-point invariance is not unique. See Sec. 26.5 (Alg. 26.2) of [1] for additional details. The original (this) descriptor is not modified.
[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction Using Java, 2nd ed, Springer (2016).
- Returns:
- an array of modified Fourier descriptors
- See Also:
-
makeScaleInvariant
Returns a new scale invariant Fourier descriptor by normalizing the L2 norm of the sub-vector {G[-mp], ..., G[-1], G[1], ..., G[mp]}. Coefficient G_0 remains unmodified. The new Fourier descriptor carries the associated scale (seegetScale()
). The original Fourier descriptor is not modified.- Returns:
- a new scale-normalized Fourier descriptor
-
makeStartPointInvariant
Returns a pair of start-point normalized Fourier descriptors. The original Fourier descriptor is not modified.- Returns:
- a pair of start-point normalized Fourier descriptors
-
makeRotationInvariant
Returns a new rotation invariant Fourier descriptor by applying complex rotation to all coefficients (except coefficient 0). The original Fourier descriptor is not modified.- Returns:
- a new rotation-normalized Fourier descriptor
-
makeTranslationInvariant
Returns a new translation invariant Fourier descriptor by setting coefficient 0 to zero. The original Fourier descriptor is not modified. This method is not used for shape invariance calculation, since position is not shape-relevant.- Returns:
- a new translation-normalized Fourier descriptor
-
getShapeFull
Reconstructs the associated 2D shape (closed contour) with N sample points, using all of the Fourier descriptor's coefficient pairs. The result is returned as an array ofComplex
values.- Parameters:
n
- number of shape points- Returns:
- reconstructed shape points
-
getShapePartial
Reconstructs the associated 2D shape (closed contour) with N sample points, using only a subset of the Fourier descriptor's coefficient pairs. The result is returned as an array ofComplex
values.- Parameters:
n
- number of shape pointsp
- the number of (low frequency) coefficient pairs to be used- Returns:
- the reconstructed shape points
-
getShapePointFull
Reconstructs a single space point of the associated shape (closed contour) at the fractional path position t ∈ [0,1], using all of the Fourier descriptor's coefficient pairs.- Parameters:
t
- path position- Returns:
- the reconstructed shape point
-
getShapePointPartial
Reconstructs a single space point of the associated shape (closed contour) at the fractional path position t ∈ [0,1], using only a subset of the Fourier descriptor's coefficient pairs.- Parameters:
p
- the number of (low frequency) coefficient pairs to be usedt
- path position ∈ [0,1]- Returns:
- the reconstructed shape point
-
getShapePair
Reconstructs the associated 2D shape (closed contour) with N sample points, using only a single coefficient pairs. The result is returned as an array ofComplex
values.- Parameters:
n
- number of shape pointsm
- the frequency index of the coefficient pair- Returns:
- the reconstructed shape points
-
getShapePointPair
Returns the spatial point reconstructed from a single DFT coefficient pair G[-m], G[+m] at position t ∈ [0,1]. Varying t creates points on an ellipse.- Parameters:
m
- frequency index (coefficient pair number)t
- contour position ∈ [0,1]- Returns:
- reconstructed shape point
-
getEllipseParameters
Returns the parameters of the geometric ellipse associated with a single Fourier coefficient pair (G[-m], G[+m]). See Sec. 26.3.5 of [1] for details. The result is in the form (ra, rb, xc, yc, theta).
[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction Using Java, 2nd ed, Springer (2016).
- Parameters:
m
- the frequency index of the Fourier coefficient pair- Returns:
- the ellipse parameters (ra, rb, xc, yc, theta)
-
getEllipse
Returns the ellipse associated with a single Fourier coefficient pair (G[-m], G[+m]) as a (AWT)
Shape
object. The resulting ellipse is centered at (0,0).AffineTransform
may be used to shift the ellipse to any other position.- Parameters:
m
- the frequency index of the Fourier coefficient pair- Returns:
- the ellipse (
Shape
) - See Also:
-
distanceComplex
Returns a L2-type distance between this and anotherFourierDescriptor
instance comparing the real and imaginary parts of all coefficient pairs. The zero-frequency coefficients are ignored.- Parameters:
fd2
- another Fourier descriptor- Returns:
- the resulting distance
-
distanceComplex
Returns a L2-type distance between this and anotherFourierDescriptor
instance comparing the real and imaginary parts of a limited range of (low-frequency) coefficient pairs. The zero-frequency coefficients are ignored.- Parameters:
fd2
- another Fourier descriptorp
- the number of (low-frequency) coefficient pairs to evaluate- Returns:
- the resulting distance
-
distanceMagnitude
Returns a L2-type distance between this and anotherFourierDescriptor
instance comparing the magnitudes of all coefficient pairs. The zero-frequency coefficients are ignored.- Parameters:
fd2
- another Fourier descriptor- Returns:
- the resulting distance
-
distanceMagnitude
Returns a L2-type distance between this and anotherFourierDescriptor
instance comparing the magnitudes of a limited range of (low-frequency) coefficient pairs. The zero-frequency coefficients are ignored.- Parameters:
fd2
- another Fourier descriptorp
- the number of (low-frequency) coefficient pairs to evaluate- Returns:
- the resulting distance
-
toString
-
toPath
-
toComplexArray
-