Fully automated: from root imaging to image analysis

Kaining Zhou

November 10, 2021

1. Automated Minirhizotron for root imaging:

A minirhizotron (MR) is an in situ root imaging system that captures root dynamics over time. Commercial MRs usually are expensive and need manual operation which is time-consuming. This results in limited observation interval and sampling amount in root studies using MR technology. The next challenge for in situ root imaging is to develop low cost and automated MR systems. We designed and developed a root imaging system which is able to overcome the limitations mentioned above. The imaging system is with fully automated operations for long-term in-situ monitoring using wireless control. Images acquired by this system has high resolution of \(2592\times 1944\) pixels. The system is tested in the field by imaging bell pepper roots showing advantageous performance over commercial systems.

Automated Minirhizotron system

Automated Minirhizotron system

2. Automated root image analysis

Though taking root images become much easier, image analysis is tedious and time-consuming.Therefore, image analysis is the bottleneck for image-based root phenotyping. There are many open-source or commercial software which can automatically analyze root images but they mainly worked on roots grown in hydroponic system or transparent soil. The lack of automated, high throughput root analysis hampers our scientific understanding and prevents application of MR in agricultural and environmental settings. There is a urgent demand to integrate innovative approaches such as machine learning into root phenotyping pipelines. In other words, we need to train computers to process and analyze root images for us.

Now we developed a imaging pipeline which is able to automatically identify roots and measure root length using Convolutional Neural Networks (CNN).

Pipeline of automated root image analysis

Pipeline of automated root image analysis

The model have been tested on thousands of root images taken from various crops(e.g. orange trees, melon, tomato, bell pepper) grown under stressed conditions(e.g. salinity, low temperature, root restriction). This model perform well on estimating root length compared with manual annotation. The code is written in python which is saved in Google drive (private access).

To run the model, every time just need to change the input path of target image folder and output path then click Run. It only takes few seconds to complete analyzing each image which is way faster than manual annotation (usually 1-2 minutes for each image).

Interface of the opration system

Interface of the opration system

3. Manual root annotation

3.1 Rootfly: Software for Minirhizotron Image Analysis
Rootfly is a free, open-source software specially designed for MR image analysis. It can be used to measure the length, diameter, color, as well as the lifespan of each individual root. This software is very handy with easy to use interface, and with all the data for an experiment stored in a single RFY file.

 

Bartz Technology Corporation (Bartz) produces most commonly used MR systems, and Rootfly is widely used to analyze images taken from Bartz MR.

Interface of the opration system

Interface of the opration system

3.2 Image requirements in Rootfly
  • Image file format
    Rootfly accepts images in either jpg or bmp formats.

     

    Rootfly expects root images adhere to common filename conventions. While the experiment, tube, window, and session of each root must be specified in the filename, while other parameters such as time and initials are optional. For example, the Bartz ICAP uses the filename format experiment_T[tube #]_L[window #]_[session date]_[time]_[session #]_[initials].jpg. In Rootfly, this image file format would be equivalent to: [expt]T[tube]L[win][yyyy.mm.dd][time]_[sess]_user].jpg. In practice, a image file of this format may appear as: EXPERIMENT_T001_L000_2007.05.09_070000_001_CBD.jpg.

     

    When the project image directory is specified, any minirhizotron image not in this format will be ignored. To learn more about making root images ready for a Rootfly project, review preparing images.

  • Image size
    There is no restriction on the size of the root images used. However, images with large size are heavy for Rootfly and may cause trouble to run it.

3.3 Prepare images for Rootfly

Followed are R codes to prepare images. Let’s break them into three parts;

  • Rename image file
    The name of images taken from automated MR do not meet the requirement of Rootfly because (1) image orders are reversed (e.g. image taken near soil surface has greater number) (2) root images do not adhere to common filename conventions.
# 1. Set working directory
setwd("C:/Users/Kaining/Desktop/Cam 3/1015formr")

# 2. Load packages
library("dplyr") # Used for piping
library("magick") # Used for stitching images

# 3. Rename images
# This step is to reverse order & add required parameters in image name
file.rename(list.files(pattern = ".jpg"), paste0("Pepperauto_T003_L",length(list.files(pattern = ".jpg")):1, "_2021.10.15_001.jpg"))

# 4. Redefine number format
# For example, change 1 to 01.Because computer considers the first file should be numbered as 01 rather than 1, this step will avoid errors when order images for later analysis or stitching.
# Write in PowerShell: 
# gci | ren -n {[regex]::replace($_.name, '\d+', {"$args".PadLeft(2, '0')})}

}
  • Resize image file
    Images taken by automated MR is as large as \(2592\times 1944\) pixels. We need to make them the same dimension as Bartz MR image (640 * 480 pixels).
#... Continued 

# 5. Resize images
listoffiles <- list.files(path = "C:/Users/Kaining/Desktop/Cam 3/1015formr",
                          full.names = TRUE) # Each time remember to change the path of image folder 

for(i in seq_along(listoffiles)) {
  
  imfile <- image_read(listoffiles[i])
  
  resized <- image_scale(imfile, "640") 
  
  image_write(resized, paste(listoffiles[i]))
  
}

When import images to Rootfly, remember to remove the parameters of time and initials in the window below.

Select image file format

Select image file format

  • Stitch images
    Sometime it is nice to show the soil profile of each tube so audience can visually see contrast rooting pattern under different conditions. Note that if put this chunk of code before resize, we could get stitched images with original resolution (able to stitch up to 32 original images with each image in 3MB).
#... Continued 

# 6. Stitch images
pics <- dir("C:/Users/Kaining/Desktop/Cam 3/1015formr", full.names = TRUE)
length_size <- length(pics)
pics[1:length_size] %>%
  image_read() %>%
  image_append(stack = TRUE) %>%
  image_write("stitched_image.jpg")
  
Stitched root images

Stitched root images