Ola Heloisa, muito obrigado pela sua pergunta.
Segue o script que você me pediu, veja que ele está automatizado para rodar em paralelo. Além disso, como você deseja extrair apenas a média dos índices, não tem problema reduzir a resolução da imagem.
Lembre-se que deve colocar todas as suas imagens em uma pasta (e.g. images/).
Boa sorte em seu trabalho e aguardo novamente qualquer outra pergunta no Fórum.
Obrigado,
Filipe Matias
### START ###
# Required packages
library(parallel)
library(foreach)
library(doParallel)
library(FIELDimageR)
library(raster)
# Images names (folder directory: "./images/")
pics<-list.files("./images/")
# Vegetation indices
index<- c("BGI", "VARI", "GLI", "NGRDI")
################
### Parallel ###
################
# Number of cores
n.core<-detectCores()-1
# Starting parallel
cl <- makeCluster(n.core, output = "")
registerDoParallel(cl)
system.time({
EX.Table.Parallel <- foreach(i = 1:length(pics), .packages = c("raster","FIELDimageR"),
.combine = rbind) %dopar% {
EX.L1<-stack(paste("./images/",pics[i],sep = ""))
EX.L1<-aggregate(EX.L1,fact=4) #Reducing image resolution (fast analysis)
EX.L.Shape<-fieldPolygon(mosaic=EX.L1, extent=T, plot=F) # extent=T (The whole image area will be the shapefile)
EX.L2<-fieldMask(mosaic=EX.L1, index="BGI", cropValue=0.8, cropAbove=T, plot=F) # Select one index to identify leaves and remove the background
EX.L4<-fieldIndex(mosaic=EX.L2$newMosaic, index=index, plot=F) # Indices
EX.L.Info<- fieldInfo(mosaic=EX.L4[[index]], fieldShape=EX.L.Shape$fieldShape, projection=F) # projection=F (Ignore projection. Normally used only with remote sensing images)
EX.L.Info$plotValue # Combine information from all images in one table
}})
rownames(EX.Table.Parallel)<-pics
EX.Table.Parallel
### END ###