License: This is an open access protocol distributed under the terms of the Creative Commons Attribution License,  which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited
This protocol is a part of BTI mobile plant phenotyping system (https://github.com/Leon-Yu0320/BTI-Plant-phenotyping). In this part, we'll introduce using jupyter book as an interactive user-friendly interface to set appropriate parameters for image analysis by PlantCV.
In particular, we developed the current workflow based on plantCV 3.12.1 by conda installation. To reduce potential errors and bugs, installing the same version will be highly recommeded. Use the following command to excute installation:
Test the first chunk of the analysis to check if the PlantCV library was loaded. See one of the following examples:
#import libraires
import os
import numpy as np
import argparse
from plantcv import plantcv as pcv
Load images for parameter adjustment
Load images for parameter adjustment
Example images can be downloaded from https://github.com/Leon-Yu0320/BTI-Plant-phenotyping/tree/main/images_example. We'll select one of the three images from two types of experiments as example to adjust parameters. Please modify the directory where exmaple images been saved under your local computer. See one the the following example:
5. extraction phenotypes from each individual plant
Each part will be tested to reach the optimum effects of phenotype data extraction. See tips for each part below:
Before executing the pipeline for each part, a quick check of image quality will be necessary. For users' image data, the following bad examples should be excluded for parameter settings and analysis:
position and white-balance corrections
After the image loading, the initial step is shifting or rotating the image at the center by using shift functions. The step is necessary which provides a framework for the selection of regions of interest (ROI). Please see two examples below;
# Shift image. This step is important for clustering later on.
# For this image it also allows you to push the green raspberry pi camera
# out of the image. This step might not be necessary for all images.
# The resulting image is the same size as the original.
# Inputs:
# img = image object
# number = integer, number of pixels to move image
# side = direction to move from "top", "bottom", "right","left"
The transformation from RGB to LAB color space is the preliminary step to isolating the plants from the background based on the nature of contrast between green objects and the background. In this protocol, we selected the "a" channel which brings the highest level of contrast between plant tissues and background.
See code for color space transformation as below:
l = pcv.rgb2gray_lab(rgb_img=img1, channel='l')
a = pcv.rgb2gray_lab(rgb_img=img1, channel='a')
b = pcv.rgb2gray_lab(rgb_img=img1, channel='b')
image masking
Effective masking from LAB transformed binary images requires the well-defined edge of plant tissues and background. Thus, a good cut-off for transformation should be selected. Attached is one example with over-masked, good-mask, and less-masked images being processed (from left to right).
See thecode for masking below:
# Set a binary threshold on the saturation channel image
# Inputs:
# gray_img = img object, grayscale
# threshold = threshold value (0-255)
# max_value = value to apply above threshold (usually 255 = white)
# object_type = light or dark
# - If object is light then standard thresholding is done
# - If object is dark then inverse thresholding is done
The ROIs define the individual plants to be included for extracting phenotypes. The coordinates of the X and Y-axis of the left-upper corner of the region, H and W are corresponded to the height and width of the ROI.
# Define region of interest (ROI)
# Inputs:
# img = An RGB or grayscale image to plot the ROI on.
# x = The x-coordinate of the upper left corner of the rectangle.
# y = The y-coordinate of the upper left corner of the rectangle.
Based on ROIs selected, a detailed division of an individual plant will be defined using a circle with a fixed circle radius. To realize a better segmentation purpose, plants should be placed at the center of the coordinate circle.
# img = The image with ROI defined
# coord = The x-coordinate and y-coordinate of the upper left corner of the
# radius = The radius of the blue circle over each individual plant
# spacing = the height and width of the distance between two circles
# nrow = the number of circles in the horizontal direction
# ncols = the numbers of circles in the vertical direction
The final phenotype extraction will be performed based on small regions defined for each plant along with results being saved with a numeric ordering (from 0-15) and planting pots without plants will be skipped.
The final output will be generated along with the edge of leaves being marked. Check if most of the desired leaf area was covered by blue edge lines.
After the image loading, shifting or rotating image is optional. If adjustment of position is needed, refer code from the MULTI_PLANT IMAGE protocol for details. Also, white balance correction is optional as shown below:
# Corrects image based on color standard and stores output as corrected_img
Effective masking from LAB and HSV transfomred binary images requires the well-defined edge of plant tissues and background. Thus, a good cut-off for transformation should be selected. In side-view image pipeline, we applied slightly different strategy by combining two separate binary images into the same channel. Specicically, we selected the V and A channel for channel integration.
Initially, users can visulize all channels at a glance for transformation. With our setups, the A and V channels are recommended and we'll merge two channels as follow
For side view images, taking images from seven angles will be recommended as representatieve input to describe leaf area of the entire plants. Quality control from image each angle per plant will be necessary before proceeding to the next batch analysis step. See examples which represent the good quality image as below: