README.md

FIELDimageR: A tool to analyze orthomosaic images from agricultural field trials in R.

This package is a compilation of functions to analyze orthomosaic images from research fields. To prepare the image it first allows to crop the image, remove soil and weeds and rotate the image. The package also builds a plot shapefile in order to extract information for each plot to evaluate different wavelengths, vegetation indices, stand count, canopy percentage, and plant height.

--------------------------------------------- ## Resources * [Installation](#Instal) * [1. Required packages](#P1) * [2. Selecting the targeted field](#P2) * [3. Rotating the image](#P3) * [4. Removing soil using vegetation indices](#P4) * [5. Building the plot shape file](#P5) * [6. Building vegetation indices](#P6) * [7. Counting the number of plants](#P7) * [8. Evaluating the canopy percentage](#P8) * [9. Extracting data from field images](#P9) * [10. Estimating plant height](#P10) * [11. Removing objects (plot, cloud, weed, etc.)](#P11) * [12. Resolution and computing time](#P12) * [13. Crop growth cycle](#P13) * [14. Multispectral images](#P14) * [15. Making plots](#P15) * [16. Saving output files](#P16) * [Contact](#P17)
--------------------------------------------- ### Installation > In order to install R/FIELDimageR from GitHub [GitHub repository](https://github.com/filipematias23/FIELDimageR), first you need to install the [devtools](https://github.com/hadley/devtools) package in R. wzxhzdk:0 > Now install R/FIELDimageR using the `install_github` function from [devtools](https://github.com/hadley/devtools) package. wzxhzdk:1 [Menu](#menu)
--------------------------------------------- ### Using R/FIELDimageR #### 1. Required packages > * **[FIELDimageR](https://github.com/filipematias23/FIELDimageR)** > * **[sp](https://CRAN.R-project.org/package=sp)** > * **[raster](https://CRAN.R-project.org/package=raster)** > * **[rgdal](https://CRAN.R-project.org/package=rgdal)** wzxhzdk:2 [Menu](#menu)
--------------------------------------------- #### 2. Selecting the targeted field from the original image > It is necessary to first reduce the image/mosaic size around the field boundaries for faster image analysis. Function to use: **`fieldCrop`**. The following example uses an image available to download here: [EX1_RGB.tif](https://drive.google.com/open?id=1S9MyX12De94swjtDuEXMZKhIIHbXkXKt). wzxhzdk:3

wzxhzdk:4

[Menu](#menu)
--------------------------------------------- #### 3. Rotating the image > To build the plot shape file first we need to make sure that the image base line (dashed in red) has a correct straight position (vertical or horizontal). If not, it is necessary to find the right-angle *theta* to rotate the field, **`fieldRotate`** allows you to click directly on the image and select two points on where you want to base your field and return the theta value to finally rotate the image. wzxhzdk:5

[Menu](#menu)
--------------------------------------------- #### 4. Removing soil using vegetation indices > The presence of soil can introduce bias in the data extracted from the image. Therefore, removing soil from the image is one of the most important steps for image analysis in agricultural science. Function to use: **`fieldMask`** wzxhzdk:6

[Menu](#menu)
--------------------------------------------- #### 5. Building the plot shape file > Once the field has reached a correct straight position, the plot shape file can be drawn by selecting at least four points at the corners of the experiment. The number of columns and rows must be informed. At this point the experimental borders can be eliminated, in the example bellow the borders were removed in all the sides. Function to use: **`fieldShape`** wzxhzdk:7

> **Attention:** The plots are identified in ascending order from left to right and top to bottom being evenly spaced and distributed inside the selected area independent of alleys.

> To identify the plots the function **`fieldMap`** can be used to include an specific plot *ID* from an external table file. The column **PlotName** in the output will be the new ID. You can dowload an example of an ID table here: [DataTable.csv](https://drive.google.com/open?id=18YE4dlSY1Czk2nKeHgwd9xBX8Yu6RCl7). wzxhzdk:8

wzxhzdk:9

wzxhzdk:10

[Menu](#menu)
--------------------------------------------- #### 6. Building vegetation indices > A general number of indices are implemented in *FIELDimageR* using the function **`indices`**. Also, yo can build your own index using the parameter `myIndex`.

wzxhzdk:11

> *Sugestion:* This function could also be used to build an index to remove soil or weeds. First it is necessary to identify the threshold to differentiate soil from the plant material. At the example below (B), all values above 0.7 were considered as soil and further removed using **`fieldMask`** (C & D). wzxhzdk:12

[Menu](#menu)
--------------------------------------------- #### 7. Counting the number of plants > *FIELDimageR* can be used to evaluate stand count during early stages. A good weed control practice should be performed to avoid misidentification inside the plot. The *mask* output from **`fieldMask`** and the *fieldshape* output from **`fieldShape`** must be used. Function to use: **`standCount`**. The parameter *n.core* is used to accelerate the counting (parallel). wzxhzdk:13

> To refine stand count, we can further eliminate weeds (small plants) or outlying branches from the output using the parameter *min Size*. The following example uses an image available to download here:[EX_StandCount.tif](https://drive.google.com/open?id=1PzWcIsYQMxgEozR5HHUhT0RKcstMOfSk) wzxhzdk:14

wzxhzdk:15

wzxhzdk:16

[Menu](#menu)
--------------------------------------------- #### 8. Evaluating the canopy percentage > *FIELDimageR* can also be used to evaluate the canopy percentage per plot. The *mask* output from **`fieldMask`** and the *fieldshape* output from **`fieldShape`** must be used. Function to use: **`canopy`**. The parameter *n.core* is used to accelerate the canopy extraction (parallel). wzxhzdk:17 [Menu](#menu)
--------------------------------------------- #### 9. Extracting data from field images > The function *extract* from **[raster](https://CRAN.R-project.org/package=raster)** is adapted for agricultural field experiments through function **`getInfo`**. The parameter *n.core* is used to accelerate the plot extraction (parallel). wzxhzdk:18 [Menu](#menu)
--------------------------------------------- #### 10. Estimating plant height > The plant height can be estimated by calculating the Canopy Height Model (CHM). This model uses the difference between the Digital Surface Model (DSM) from the soil base (before there is any sproute, [Download EX_DSM0.tif](https://drive.google.com/open?id=1lrq-5T6x_GrbkCtpDSDiX1ldvSwEBFX-)) and the DSM file from the vegetative growth (once plants are grown, [Download EX_DSM1.tif](https://drive.google.com/open?id=1q_H4Ef1f1yQJOPtkVMJfcb2SvHcxJ3ya)). To calculate the plant height, first we used a previously generated *mask* from step 4 to remove the soil, and the output from *fieldshape* in step 5 to assign data to each plot. The user can extract information using the basic R functions mean, max, min, and quantile as a parameter in function **`getInfo`**. wzxhzdk:19

[Menu](#menu)
--------------------------------------------- #### 11. Removing objects (plot, cloud, weed, etc.) > The function **`fieldCrop`** can be used to remove objects from the field image. For instance, the parameter *remove=TRUE* and *nPoint* should be used to select the object boundaries to be removed. [Download EX_RemObj.tif](https://drive.google.com/open?id=1wfxSQANRrPOvJWwNZ6UU0UjXwzKfkKH0)). wzxhzdk:20

[Menu](#menu)
--------------------------------------------- #### 12. Resolution and computing time > The influence of image resolution was evaluated at different steps of the FIELDimageR pipeline. For this propose, the resolution of image *EX1_RGB_HighResolution.tif* [Download](https://drive.google.com/open?id=1elZe2jfq4bQSZM8cFAS4q7fRrnXbSBgH) was reduced using the function **raster::aggregate** in order to simulate different flown altitudes Above Ground Surface (AGS). The parameter *fact* was used to modify the original image resolution (0.4x0.4 cm with 15m AGS) to: first, **fact=2** to reduce the original image to 0.8x0.8 cm (simulating 30m AGS), and **fact=4** to reduce the original image to 1.6x1.6 (simulating 60m AGS). The steps (*i*) cropping image, (*ii*) removing soil, (*iii*) rotating image, (*iv*) building vegetation index (BGI), and (*v*) getting information were evaluated using the function **system.time** output *elapsed* (R base). wzxhzdk:21 > The time to run one function using the image with pixel size of 0.4x0.4 cm can be 10 (**`getInfo`**) to 70 times (**`indices`**) slower than the image with pixel size of 1.6x1.6 cm (Table 1). The computing time to extract BGI index (one layer) with 0.4x0.4 cm was ~23 min whereas only ~7 min with the 0.8x0.8 cm image, and ~2 min using the 1.6x1.6 cm image. the time to extract the RGB information (three layers) was ~2.3 min for the 1.6x1.6 cm image and ~66 min for the 0.4x0.4 cm image. It is important to highlight that the resolution did not affect the plots mean, it has a correlation >99% between 0.4x0.4 cm and 1.6x1.6 (Table 2). High resolution images showed to require higher computational performance, memory, and storage space. We experienced that during the image collection in the field a low altitudes flight needs more batteries and a much greater number of pictures, and consequently longer preprocessing images steps to build ortho-mosaics.

[Menu](#menu)
--------------------------------------------- #### 13. Crop growth cycle > The same rotation theta from step 3, mask from step 4, and plot shape file from step 5, can be used to evaluate mosaics from other stages in the crop growth cycle. Here you can download specific images from flowering and senecense stages in potatoes. ([**Flowering: EX2_RGB.tif**](https://drive.google.com/open?id=1B1HrIYUVqSpKdDN8E8VudpI8jT8MYbWY) and [**Senescence: EX3_RGB.tif**](https://drive.google.com/open?id=15GpLy669mICpkorbUk1M9vqfSUMHbdc5)) wzxhzdk:22

[Menu](#menu)
--------------------------------------------- #### 14. Multispectral images > **`FIELDimageR`** can be used to analyze multispectral images. The same rotation theta, mask, and plot shape file used to analyze RGB mosaic above can be used to analyze multispectral mosaic from the same field. You can dowload an example here: [**EX1_5Band.tif**](https://drive.google.com/open?id=1vYb3l41yHgzBiscXm_va8HInQsJR1d5Y) > **Attention:** HYPERSPECTRAL images were not tested in *`FIELDimageR`* wzxhzdk:23 [Menu](#menu)
--------------------------------------------- #### 15. Making plots > Graphic visualization of trait values for each plot using the **fieldShape file** and the **Mosaic** of your preference. Function to use: **`fieldPlot`**. wzxhzdk:24

[Menu](#menu)
--------------------------------------------- #### 16. Saving output files wzxhzdk:25 [Menu](#menu)
--------------------------------------------- ### YouTube Tutorial > FIELDimageR: A tool to analyze orthomosaic images from agricultural field trials in R (Basic Pipeline)

> FIELDimageR: Counting the number of plants (StandCount)

> FIELDimageR: calculating vegetation indices (NDVI and NDRE)

### Google Groups Forum > This discussion group provides an online source of information about the FIELDimageR package. Report a bug and ask a question at https://groups.google.com/forum/#!forum/fieldimager ### Licenses > The R/FIELDimageR package as a whole is distributed under [GPL-2 (GNU General Public License version 2)](https://www.gnu.org/licenses/gpl-2.0.en.html). ### Author > * [Filipe Inacio Matias](https://github.com/filipematias23) ### Acknowledgments > * [University of Wisconsin - Madison](https://horticulture.wisc.edu) > * [UW Potato Breeding and Genetics Laboratory](https://potatobreeding.cals.wisc.edu) > * [Dr Jeffrey Endelman, PhD Student Maria Caraza-Harter, and MS Student Lin Song](https://potatobreeding.cals.wisc.edu/people/) [Menu](#menu)


angel30mpa/ampa documentation built on Feb. 22, 2020, 12:17 a.m.