#load and plot one example #install.packages("geomorph") #uncomment if you do not have the package installed library(geomorph) #load the data, note that example_AI.tps needs to be in a same folder as this script or you wuld need to specify the path d<- readland.tps("example_AI.tps", specID = "imageID") # load definitions of semilandmarks and links between points for nice plotting slids<- read.table("slidersR.txt") links<- read.table("linksR.txt") # Perform Generalized Procrustes Analysis (GPA), align the configurations to minimize the sum of squared distances between corresponding landmarks gpa <- gpagen(d,curves = slids, PrinAxes = F, ProcD = T) #Setting the grid parameters, there are many more options, see the documentation of geomorph package GP1<-gridPar(link.lwd = 1.8, tar.pt.size=0.1,grid.col = "grey65") #Plotting just the face over a rectangular grid par(mar=c(0,0,0,0)) plotRefToTarget(gpa$coords[,,1],gpa$coords[,,1],links=links, gridPars = GP1) #Plotting the face as a deformation of the underlying grid mean<-mshape (gpa$coords) plotRefToTarget(mean,gpa$coords[,,1],links=links, gridPars = GP1) #Caricaturing the difference by using twice the difference magnitude plotRefToTarget(mean,gpa$coords[,,1],links=links, gridPars = GP1,mag=2) #try other faces by modifying the "floor" number of the gpa$coords array