efourier_shape function

Draw shapes based on Fourier coefficients

Draw shapes based on Fourier coefficients

Calculates a 'Fourier elliptical shape' given Fourier coefficients

efourier_shape( an = NULL, bn = NULL, cn = NULL, dn = NULL, n = 1, nharm = NULL, npoints = 150, alpha = 4, plot = TRUE )

Arguments

  • an: The ana_n Fourier coefficients on which to calculate a shape.
  • bn: The bnb_n Fourier coefficients on which to calculate a shape.
  • cn: The cnc_n Fourier coefficients on which to calculate a shape.
  • dn: The dnd_n Fourier coefficients on which to calculate a shape.
  • n: The number of shapes to generate. Defaults to 1. If more than one shape is used, a list of coordinates is returned.
  • nharm: The number of harmonics to use. It must be less than or equal to the length of *_n coefficients.
  • npoints: The number of points to calculate.
  • alpha: The power coefficient associated with the (usually decreasing) amplitude of the Fourier coefficients.
  • plot: Logical indicating Whether to plot the shape. Defaults to ´TRUE`

Returns

A list with components:

  • x vector of x-coordrdinates
  • y vector of y-coordrdinates.

Details

efourier_shape can be used by specifying nharm and alpha. The coefficients are then sampled in an uniform distribution (π;π)(-\pi ; \pi) and this amplitude is then divided by c("harmonicrank\nharmonicrank ^\n", "alphaalpha"). If alpha is lower than 1, consecutive coefficients will thus increase. See Claude (2008) pp.223 for the maths behind inverse ellipitical Fourier

Adapted from Claude (2008). pp. 223.

Examples

if (interactive() && requireNamespace("EBImage")) { library(pliman) # approximation of the third leaf's perimeter # 4 harmonics image_pliman("potato_leaves.jpg", plot = TRUE) efourier_shape(an = c(-7.34, 1.81, -1.32, 0.50), bn = c(-113.88, 21.90, -0.31, -6.14), cn = c(-147.51, -20.89, 0.66, -14.06), dn = c(-0.48, 2.36, -4.36, 3.03)) }

References

Claude, J. (2008) Morphometrics with R, Use R! series, Springer 316 pp.