#Revise to get root
filroot<- "FriAug22VectScnImg0336"
require(pixmap)
XXa<-attributes(read.pnm(paste(filroot,"a.ppm",sep='')))
XXb<-attributes(read.pnm(paste(filroot,"b.ppm",sep='')))
XXc<-attributes(read.pnm(paste(filroot,"c.ppm",sep='')))
XXd<-attributes(read.pnm(paste(filroot,"d.ppm",sep='')))
XXe<-attributes(read.pnm(paste(filroot,"e.ppm",sep='')))
XXf<-attributes(read.pnm(paste(filroot,"f.ppm",sep='')))

XXred<- (XXa$red+XXb$red+XXc$red+XXd$red+XXe$red+XXf$red)/6
XXblu<- (XXa$blue+XXb$blue+XXc$blue+XXd$blue+XXe$blue+XXf$blue)/6
XXgre<- (XXa$green+XXb$green+XXc$green+XXd$green+XXe$green+XXf$green)/6
dat<- array(c(XXred, XXgre, XXblu), c(attributes(XXred)$dim,3))
XX<- pixmapRGB(dat)

write.pnm(XX, file=paste(filroot,"avg.ppm",sep=''))
cat("Done\n") 