# Preliminaries library("Momocs") # Figure 3 #### dove <- import.jpg("Dove.jpg")[[1]] dove <- coo.slide(coo.center(dove), 1750) par(cex = 0.8) layout(matrix(1:4, nc = 2, byrow = TRUE)) coo.plot(dove, border = NA, col = "808080", las = 1) bary <- apply(dove, 2, mean) points(bary[1], bary[2], pch = 3) dove2 <- coo.sample(dove, 20) text(dove2[, 1], dove2[, 2], labels = as.character(1:20)) # Tangent angle dove2t1 <- tfourier(dove2, nb.h = 10) dove2t <- (dove2t1$phi + dove2t1$thetao) %% 2*pi par(xpd = NA) plot(1:20, dove2t, ylim = c(0, 2*pi), type = "b", axes = FALSE, ann = FALSE, pch = "", las = 1) text(1:20, dove2t, labels = as.character(1:20)) title(main = "Tangent angle", xlab = "Points along the outline", ylab = "Tangent angle (radians)") axis(1, at = c(0, 5, 10, 15, 20)) axis(2, at = seq(0, 2*pi, pi/2), labels = c(0, "pi/2", "pi", "3pi/2", "2pi"), las = 1) # Radius variation dove2r <- rfourier(dove2, nb.h = 10)$r par(xpd = NA) plot(1:20, dove2r, ylim = c(0, 500), type = "b", axes = FALSE, ann = FALSE, pch = "", las = 1) text(1:20, dove2r, labels = as.character(1:20)) title(main = "Radius variation", xlab = "Points along the outline", ylab = "Radius length (pixels)") axis(1, at = c(0, 5, 10, 15, 20)) axis(2, at = seq(0,500, 100), las = 1) # Elliptical analysis dove2e <- coo.oscillo(dove2, method = "d0", plot = FALSE) par(xpd = NA) plot(NA, xlim = c(1, 20), ylim = c(-750, 250), axes = FALSE, ann = FALSE, pch = "", las = 1) segments(0, 0, 20, 0, col = "#808080", lty = 2) lines(1:20, dove2e$x, pch = "", type = "b", col = "blue") text(1:20, dove2e$x, labels = as.character(1:20)) lines(1:20, dove2e$y, pch = "", type = "b", col = "red") text(1:20, dove2e$y, labels = as.character(1:20)) title(main = "Elliptical analysis", xlab = "Points along the outline", ylab = "Deviation from the first point (pixels)") axis(1, at = c(0, 5, 10, 15, 20)) axis(2, at = seq(-750, 250, 200), las = 1) legend("topright", col = c("blue", "red"), lty = 1, legend = c("dx", "dy"), bty = "n") layout(matrix(1)) # Figure 4 #### heart <- import.jpg("Heart.jpg")[[1]] Ptolemy(Coo(list(heart = heart)), nb.h = 3, t = seq(0, 2*pi, pi/2), legend = TRUE) # Figure 5 #### data("bot", package = "Momocs") panel(bot, cols = rep(col.sari(2), each = 20), borders = "black") bot # Figure 6 #### hqual(bot, method = "eFourier", id = 16, harm.range = 1:49, palette = col.sari, plot.method = "panel") # Figure 7 #### hquant(bot, harm.range = c(12, 16, 20, 24, 32)) # Figure 8 #### hpow(bot) botF <- eFourier(bot, nb.h = 20) botF # Figure 9 #### hcontrib(botF, harm.range = 1:8) par(xpd = FALSE) boxplot(botF) # Figure 10 #### botF <- eFourier(bot, nb.h = 20) botD <- pca(botF) dudi.plot(botD, pos.shp = "circle", neighbors = TRUE) dudi.plot(botD, 1, pch = 20, eigen = TRUE, scale.shp = 0.5, amp.shp = 1.5, rug = FALSE) manova.Coe(botF, "type") # Figure 11 #### clust(botF) # Figure 12 #### botFg <- meanShapes(botF) tps.grid(botFg$beer, botFg$whisky) tps.arr(botFg$beer, botFg$whisky, amp = 2, arr.nb = 500, palette = col.sari) tps.iso(botFg$beer, botFg$whisky, iso.nb = 2000, amp = 2)