library(pliman)
leaf1 <- contours[[4]]
plot_polygon(leaf1)
#### default options
# 10 harmonics (default)
# without alignment
ef <- efourier(leaf1)
efourier_coefs(ef)
# object is aligned along the major caliper with `poly_align()`
# object is centered on the origin with `poly_center()`
# using a list of object coordinates
ef2 <- efourier(contours, align = TRUE, center = TRUE)
efourier_coefs(ef2)
# reconstruct the perimeter of the object
# Use only the first one for simplicity
plot_polygon(contours[[1]] |> poly_align() |> poly_center())
efourier_inv(ef2[[1]]) |> plot_contour(col = "red", lwd = 4)
Run the code above in your browser using DataLab