## Supplemental File 1. R-script for photo image analysis of seed size and dimensions. Scan.Silphium <- function(singlePhoto){ library(EBImage) ## define minimum and maximium areas minArea<-100 maxArea<-1000000 # Thresholding A.1 <- readImage(singlePhoto) B <- EBImage::channel(A.1, mode = 'blue') ## change here if other using other channel for thresholding binaryImage <- EBImage::fillHull(B) labeledImage <- EBImage::bwlabel(binaryImage) ## checking the sizes of the objects tt<-table(labeledImage) ## removing the ones that dont fit the minArea and maxArea parameters tt2<-which(ttmaxArea) labeledImage[which(labeledImage %in% as.numeric(names(tt)[tt2]))]<-0 ## just checking #display(labeledImage) A<-A.1 A[which(labeledImage==0)]<-NA #display(A) ttE<-table(labeledImage)[-1] res<-matrix(NA,nrow=length(ttE),ncol=5) cont<-1 for (i in names(ttE)){ f<-which(labeledImage==i,arr.ind = TRUE) xs<-c(min(f[,1]),max(f[,1])) ys<-c(min(f[,2]),max(f[,2])) singleSeed<-A[xs[1]:xs[2],ys[1]:ys[2],] binImage<-(channel(singleSeed,'grey'))^3 ## red part g1<-which(binImage<.4,arr.ind = TRUE) for (j in 1:nrow(g1)){ singleSeed[g1[j,1],g1[j,2],]<-c(1,0,0) } ## blue part g<-which(binImage>=.4,arr.ind = TRUE) for (j in 1:nrow(g)){ singleSeed[g[j,1],g[j,2],]<-c(0,0,1) } x<-c(min(g[,1]),max(g[,1])) y<-c(min(g[,2]),max(g[,2])) blueSeed<-singleSeed[x[1]:x[2],y[1]:y[2],3] tmp<-EBImage::bwlabel(blueSeed) tt<-table(tmp) ttt<-tt[-which(tt<100)] tttt<-blueSeed[which(tmp==names(ttt)[1],arr.ind = FALSE)[1]]+1 ttt<-ttt[-tttt] tmp[which(tmp!=as.numeric(names(ttt)))]<-0 res[cont,]<-c(computeFeatures.shape(tmp,blueSeed)[c(2,5,6)],nrow(g),nrow(g1)) for (j in 1:3){ A[xs[1]:xs[2],ys[1]:ys[2],j]<-singleSeed[,,j] } #cat(paste0('object ',cont,' done\n')) cont<-cont+1 } resA<-as.data.frame(res) colnames(resA)<-c('perimeter','seed.width','seed.length','seed.area','achene.area') resA$seed.width <- resA$seed.width * 2 resA$seed.length <- resA$seed.length *2 #display(A) return(list(return.data = resA,original.image = A.1, extracted.image = A, photo = singlePhoto)) }