Learn R Programming

Momocs (version 0.2-03)

ef.amplify: Dilates shapes based on elliptical Fourier decomposition.

Description

These two functions calculate dilated and eroded shapes based on elliptical Fourier decomposition i.e. taking into account the shape as a whole. Lists created by efourier objects can be passed to ef.amplify or a list or matrix of coordinates to coo.ef.amplify.

Usage

ef.amplify(ef, amp=rep(0.5, 4))
coo.ef.amplify(coo, amp=rep(0.5, 4), nb.h=5, draw=FALSE, ...)

Arguments

ef
list. A list containing $a_n$, $b_n$, $c_n$ and $d_n$ Fourier coefficients, such as returned by efourier.
coo
A list or a matrix of coordinates.
amp
A vector of numeric. If amp is of length 4, the value specify the multiplication factor for $a_1$, $b_1$, $c_1$ and $d_1$ ; if only one value is provided, then the multiplication factor will be the same for the four coefficients
draw
logical. Whether to draw (see coo.draw) the amplified coo.
nb.h
integer. The number of harmonics to calculate.
...
Additional parameters to be passed to coo.draw.

Value

  • ef.amplify returns the ef provided but with "amplified" coefficients for the first harmonics. coo.amplify returns the coo provided but "amplified" based on elliptical Fourier.

See Also

efourier for a description of the elliptical Fourier analysis and Ptolemy for an illustration of the first ellipse/harmonic defining the shape "amplitude".

Examples

Run this code
# same amp factor for every coeff.
data(bot)
bot1 <- coo.sample(bot@coo[[1]], 50)
coo.plot(bot1, col=NA)
amp <- seq(0.9, 0.3, -0.1)
for (i in seq(along=amp)) {
  coo.ef.amplify(bot1, amp[i], draw=TRUE, first=FALSE,
              col=NA, border=col.summer(length(amp))[i])}

# random shape, separate amplification
poly <- efourier.shape(nb.h=5, alpha=3, plot=FALSE)
poly2 <- coo.sample(poly, 20)
layout(matrix(1:4, nc=2, byrow=TRUE))
par(oma=rep(0.5, 4), mar=c(2, 2, 3, 2))
coo.plot(poly2, col=NA, main="an")
for (i in seq(-1, 1, 0.5)) {
  coo.ef.amplify(poly2, c(i, 1, 1, 1), draw=TRUE)}

coo.plot(poly2, col=NA, main="bn")
for (i in seq(-1, 1, 0.5)) {
  coo.ef.amplify(poly2, c(1, i, 1, 1), draw=TRUE)}

coo.plot(poly2, col=NA, main="cn")
for (i in seq(-1, 1, 0.5)) {
  coo.ef.amplify(poly2, c(1, 1, i, 1), draw=TRUE)}

coo.plot(poly2, col=NA, main="dn")
for (i in seq(-1, 1, 0.5)) {
  coo.ef.amplify(poly2, c(1, 1, 1, i), draw=TRUE)}

Run the code above in your browser using DataLab