idx<-seq(0,6.28,len=100);
query<-sin(idx)+runif(100)/10;
template<-cos(idx)
alignment<-dtw(query,template);
wq<-warp(alignment,index.template=FALSE);
wt<-warp(alignment,index.template=TRUE);
old.par <- par(no.readonly = TRUE);
par(mfrow=c(2,1));
plot(template,main="Warping query");
lines(query[wq],col="blue");
plot(query,type="l",col="blue",
main="Warping template");
points(template[wt]);
par(old.par);
##############
##
## Asymmetric step makes it "natural" to warp
## the template, because every query index has
## exactly one image (q->t is a function)
##
alignment<-dtw(query,template,step="a")
wt<-warp(alignment,index.template=TRUE);
plot(query,type="l",col="blue",
main="Warping template, asymmetric step");
points(template[wt]);
Run the code above in your browser using DataLab