Hi Maria, thank you for asking.
Please, see if the script below can help you.
Best,
Filipe
### Script – Seeds disease ###
# Packages:
library(FIELDimageR)
library(raster)
# Input image:
EX1<-stack("4.jpg")
plotRGB(EX1, r = 1, g = 2, b = 3)
# Choosing the index to remove the background:
EX1.I1<- fieldIndex(mosaic = EX1,index = c("BI","SCI","BGI","HUE"))
plot(EX1.I1$SCI)
# Removing the background (cropping above 0.4):
EX1.R1<- fieldMask(mosaic = EX1,index = "SCI",
cropValue = 0.4,
cropAbove = T)
# Seed selection:
par(mfrow=c(1,2))
plotRGB(EX1, r = 1, g = 2, b = 3)
plotRGB(EX1.R1$newMosaic, r = 1, g = 2, b = 3)
par(mfrow=c(1,1))
# Percentage of the image with seeds (22% of the image has seeds. This information can be used as a reference to compare images):
EX1.A1<-fieldArea(mosaic = EX1.R1$mask)
# Choosing the index to identify the disease area:
EX1.I2<- fieldIndex(mosaic = EX1.R1$newMosaic,index = c("BI","GLI","SI","VARI"))
# Affected region:
par(mfrow=c(1,2))
plotRGB(EX1.R1$newMosaic, r = 1, g = 2, b = 3)
plot(EX1.I2$BI)
par(mfrow=c(1,1))
# Identifying only disease area (crop below 0.7)
EX1.R2<- fieldMask(mosaic = EX1.R1$newMosaic,
index = "BI",
cropValue = 140,
cropAbove = T)
# Percentage area affected by the disease (27% of the seed area has dark regions. This information refers only to the proportion with seeds):
EX1.A2<-fieldArea(mosaic = EX1.R2$mask)
plotRGB(EX1.R2$newMosaic)
# An extra information about how viewing yellowed regions:
par(mfrow=c(1,2))
plotRGB(EX1.R1$newMosaic, r = 1, g = 2, b = 3)
plot(EX1.I2$SI)
par(mfrow=c(1,1))
Example of output: