Eu tentei rodar o exemplo da Embrapa, mas na hora de contar as sementes esverdeadas os pontos foram colocados onde não há sementes.
# Necessary packages
library(FIELDimageR)
library(raster)
library(ggplot2)
library(agricolae)
library(reshape2)
library(lme4)
# Uploading one image as example and decreasing the resolution
EX1<-stack("soybean/11.jpg")
EX1<-aggregate(EX1, fact= 4)
plotRGB(EX1)
# extent=T (The whole image area will be the shapefile)
EX.shapeFile<-fieldPolygon(EX1,extent = T)
# Select one index to identify leaves and remove the background
EX1.I1<- fieldIndex(mosaic = EX1,index = c("SI","BGI","BI"))
# Thresholding
dev.off()
par(mfrow=c(1,2))
hist(EX1.I1$BGI)
plot(EX1.I1$BGI)
# Removing the background
EX1.R1<- fieldMask(mosaic = EX1, index = "BGI",
cropValue = 0.7,
cropAbove = T)
# Counting the total number of seeds
EX.P.Total<-fieldCount(mosaic = EX1.R1$mask,
fieldShape = EX.shapeFile$fieldShape,
minSize = 0.1,
cex = 1.5,
na.rm = T)
# Select one index to identify green seeds
EX1.I2<- fieldIndex(mosaic = EX1.R1$newMosaic,index = c("SI","BGI","BI"))
#BI index
plot(EX1.I2$BI)
# Selecting green seeds
EX1.R2<- fieldMask(mosaic = EX1.R1$newMosaic,
index = "BI",
#myIndex = "Blue",
cropValue = 130,
cropAbove = T)
# Counting the number of green seeds
EX.Green<-fieldCount(mosaic = EX1.R2$mask,
fieldShape = EX.shapeFile$fieldShape,
minSize = 0.07,
cex = 1.5,
na.rm = T)
# Joying information
data.frame(Total=EX.P.Total$fieldCount,
Green=EX.Green$fieldCount,
Percentage=round(EX.Green$fieldCount/EX.P.Total$fieldCount,2))
Foto das contagens:
A versão do R é R x64 3.6.3
e do R Studio Version 1.2.5042