Josh,
Thank you… I appreciate your email and your question.
Unfortunately, you can't input coordinates yet. But I believe you can use 3 different strategies:
1) 1) The whole image area will be the shapefile:
ShapeFile<-fieldPolygon(mosaic, extent=T)
2) 2) Select any shape format with 5 points in the center:
ShapeFile<-fieldPolygon(mosaic, nPolygon = 1, nPoint = 5)
3) 3) Select a specific square shape with 4 points in the center:
ShapeFile<-fieldShape(mosaic, ncols = 1, nrows = 1)
If you decide to use number 1, you can follow the script at the link https://github.com/filipematias23/FIELDimageR#P19
If you decide to use number 2 or 3, you should first draw one shapefile using only one image as an example and then you should use this shapefile to all other images. In other words:
# Images names (folder directory: "./images/")
pics<-list.files("./images/")
# Vegetation indices
index<- c("BGI","VARI","SCI")
# NEW PART: Same shapefile for all images (for example, using image 1 to select the center area and applying this same shapefile for all other images)
EX.image1<-stack(paste("./images/",pics[1],sep = ""))
# Option 2:
EX.L.Shape<-fieldPolygon(mosaic=EX. image1, nPolygon = 1, nPoint = 5)
# Option 3:
EX.L.Shape <-fieldShape(mosaic=EX. image1, ncols = 1, nrows = 1)
############
### Loop ###
############
system.time({ # system.time: used to compare the processing time using loop and parallel
EX.Table.Loop<-NULL
for(i in 1:length(pics)){
EX.L1<-stack(paste("./images/",pics[i],sep = ""))
plotRGB(EX.L1)
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.L3<-fieldMask(mosaic=EX.L2$newMosaic, index="VARI", cropValue=0.1, cropAbove=T, plot=F) # Select one index to identify demaged area in the leaves
EX.L4<-fieldIndex(mosaic=EX.L2$newMosaic, index=index, plot=F) # Indices
EX.L5<-stack(EX.L3$mask, EX.L4[[index]]) # Making a new stack raster with new layers (demage area and indices)
EX.L.Info<- fieldInfo(mosaic=EX.L5, fieldShape=EX.L.Shape$fieldShape, projection=F) # projection=F (Ignore projection. Normally used only with remote sensing images)
plot(EX.L5,col = grey(1:100/100))
EX.Table.Loop<-rbind(EX.Table.Loop, EX.L.Info$plotValue) # Combine information from all images in one table
}})
rownames(EX.Table.Loop)<-pics
EX.Table.Loop
Let me know if this answers your question. Also, help me to develop more scripts showing how to use FIELDimageR and help more people.
Best,
Filipe
Josh,
Thank you… I appreciate your email and your question.
I believe you can use 3 different strategies:
1) 1) The whole image area will be the shapefile:
ShapeFile<-polygonShape(mosaic, extent=T)
2) 2) Select any shape format with 5 points in the center:
ShapeFile<-polygonShape(mosaic, nPolygon = 1, nPoint = 5)
3) 3) Select a specific square shape with 4 points in the center:
ShapeFile<-fieldShape(mosaic, ncols = 1, nrows = 1)
If you decide to use number 1, you can follow the script at the link https://github.com/filipematias23/FIELDimageR#P19
If you decide to use number 2 or 3, you should first draw one shapefile using only one image as an example and then you should use this shapefile to all other images. In other words:
# Images names (folder directory: "./images/")
pics<-list.files("./images/")
# Vegetation indices
index<- c("BGI","VARI","SCI")
# NEW PART: Same shapefile for all images (for example, using image 1 to select the center area and applying this same shapefile for all other images)
EX.image1<-stack(paste("./images/",pics[1],sep = ""))
# Option 2:
EX.L.Shape<-polygonShape(mosaic=EX. image1, nPolygon = 1, nPoint = 5)
# Option 3:
EX.L.Shape <-fieldShape(mosaic=EX. image1, ncols = 1, nrows = 1)
############
### Loop ###
############
system.time({ # system.time: used to compare the processing time using loop and parallel
EX.Table.Loop<-NULL
for(i in 1:length(pics)){
EX.L1<-stack(paste("./images/",pics[i],sep = ""))
plotRGB(EX.L1)
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.L3<-fieldMask(mosaic=EX.L2$newMosaic, index="VARI", cropValue=0.1, cropAbove=T, plot=F) # Select one index to identify demaged area in the leaves
EX.L4<-indices(mosaic=EX.L2$newMosaic, index=index, plot=F) # Indices
EX.L5<-stack(EX.L3$mask, EX.L4[[index]]) # Making a new stack raster with new layers (demage area and indices)
EX.L.Info<- getInfo(mosaic=EX.L5, fieldShape=EX.L.Shape$fieldShape, projection=F) # projection=F (Ignore projection. Normally used only with remote sensing images)
plot(EX.L5,col = grey(1:100/100))
EX.Table.Loop<-rbind(EX.Table.Loop, EX.L.Info$plotValue) # Combine information from all images in one table
}})
rownames(EX.Table.Loop)<-pics
EX.Table.Loop
Let me know if this answers your question. Also, help me to develop more scripts showing how to use FIELDimageR and help more people.
Best,
Filipe
--
You received this message because you are subscribed to the Google Groups "FIELDimageR: A R package to analyze orthomosaic images from field trials." group.
To unsubscribe from this group and stop receiving emails from it, send an email to FIELDimageR...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/FIELDimageR/1791be7f-e9e6-4c23-99f8-472ace3f5fe6%40googlegroups.com.