Hi Ahasan,
Maybe you are using a old script ... It changes a bit to adapt to new packages.
Now you need to use the function EX<-imgLAB(EX)
################
### Parallel ###
################
# Required packages
library(parallel)
library(foreach)
library(doParallel)
# Images names (folder directory: "./soybean/")
pics<-list.files("./soybean/")
# Number of cores
n.core<-2
# Starting parallel
cl <- makeCluster(n.core, output = "")
registerDoParallel(cl)
EX.Table.Parallel <- foreach(i = 1:length(pics), .packages = c("stars","sf","terra","FIELDimageR"),
.combine = rbind) %dopar% {
EX3<-rast(paste("./soybean/",pics[i],sep = ""))
EX3<-imgLAB(EX3)
# Removing the background
EX3.R<- fieldMask(mosaic = EX3, index = "BGI",
cropValue = 0.7,
cropAbove = T)
# Counting the total number of seeds
EX.P.Total<-fieldCount(mosaic = EX3.R$mask,plot = T)
Total=EX.P.Total[EX.P.Total$area>15000,]
# Selecting green seeds
EX3.R2<- fieldMask(mosaic = EX3.R$newMosaic,
index = "BI",
cropValue = 130,
cropAbove = T)
# Counting the number of green seeds
EX.Green<-fieldCount(mosaic = EX3.R2$mask,plot = T)
Green=EX.Green[EX.Green$area>10800,]
data.frame(Total=dim(Total)[1],
Green=dim(Green)[1],
Percentage=round(dim(Green)[1]/dim(Total)[1],2))
}
stopCluster(cl)
rownames(EX.Table.Parallel)<-pics
EX.Table.Parallel
Hope it helps,
Filipe