Remove soil in orthomosaic of DJI Mavic 3 Multispectral

49 views
Skip to first unread message

Alexandre Santos (ASANTOS)

unread,
Dec 17, 2024, 7:18:32 PM12/17/24
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Hi, I am trying to use the fieldMask function from the FIELDimageR package to remove soil from a raster image. I am using the following code:

# Packages
library(FIELDimageR)
library(FIELDimageR.Extra)
library(raster)
library(terra)
library(mapview)
library(sf)
library(stars)


# Uploading an example mosaic
https://drive.google.com/file/d/1JA7rrc8nU9T37HBQuidtcT3C3yoceISQ/view?usp=sharing
EX1 <- rast("odm_orthophoto.tif")

# Removing soil using vegetation indices
EX1.RemSoil <- fieldMask(mosaic = EX1, ...)

I have a problem here because I don't know the meaning of each 4 bands in the mosaic (odm_orthophoto.tif). I create the mosaic using
ODM and my input images directory is composed of R, G, NIR and RE (Mavic 3 Multispectral).
Please, could you help me understand the meaning of each band in the mosaic so that I can use it the remove soil function?

Thanks in advance. 

Filipe Matias

unread,
Dec 18, 2024, 6:56:35 AM12/18/24
to FIELD...@googlegroups.com
Hi there,

Here are some suggestions: (1) Find and use a different index on fieldMask, and (2) Use Kmeans to find the soil pixels and use it as a reference mask. Hope it helps! 

### Script ###

library(terra)
library(FIELDimageR)
library(FIELDimageR.Extra)


EX1 <- rast("odm_orthophoto.tif")
fieldView(EX1)
plot(EX1)

### Option 1: Using other index ###

# You can trick the software just by pointing any layer for blue
Index<-fieldIndex(EX1,
                  Red = 1,
                  Green = 2,
                  Blue = 1,
                  RedEdge = 4,
                  NIR = 3,
                  index = c("SCI","NGRDI",
                            "PSRI","NDVI",
                            "TVI","CVI",
                            "CIG","CIRE","DVI")) # Choose only indices without Blue: https://github.com/OpenDroneMap/FIELDimageR?tab=readme-ov-file#p6

plot(Index$TVI) #Find the best Index and the cropValue


# Removing soil using vegetation indices
EX1.RemSoil <- fieldMask(mosaic = EX1,
                         Red = 1,
                         Green = 2,
                         Blue = 1,
                         RedEdge = 4,
                         NIR = 3,
                         index = "TVI",
                         cropValue = 3,
                         cropAbove = F)

### Option 2: Using Kmeans ###

EX1.Kmeans <- fieldKmeans(mosaic = EX1,clusters = 3) #Plants are Number 1

fieldView(EX1.Kmeans)

# Check which cluster is related to plants or soil based on the color. In this example cluster 1 represents plants and cluster 2 represents soil
library(leafsync)
rgb<-fieldView(EX1)
plants<-fieldView(EX1.Kmeans==1)
sync(rgb,plants)

# Soil Mask (cluster 2) to remove soil effect from the mosaic using FIELDimageR::fieldMask :
soil<-EX1.Kmeans==2
Test.RemSoil<-fieldMask(EX1,
                        mask = soil)
fieldView(Test.RemSoil$newMosaic)

###END##

--
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 visit https://groups.google.com/d/msgid/FIELDimageR/de571a13-befa-4736-bd11-eb87cc20448dn%40googlegroups.com.

Alexandre Santos

unread,
Dec 18, 2024, 7:34:41 AM12/18/24
to FIELD...@googlegroups.com
Hi Filipe,

Thank you very much for the suggestion code it helps a lot. 

Best wishes,

Alexandre

You received this message because you are subscribed to a topic in the Google Groups "FIELDimageR: A R package to analyze orthomosaic images from field trials." group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/FIELDimageR/ii4k3YJbfWQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to FIELDimageR...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/FIELDimageR/CABDapfrf%2BRC67eUAJ1r_%3Ds6%2B4DLWQcnbOkbLFZQDpY1WsafFWQ%40mail.gmail.com.


--
Alexandre dos Santos
Reply all
Reply to author
Forward
0 new messages