When starting an image-based phenotyping project it is important to consider what the end goals of the project are. This is important because the goals of the project will determine the the camera type, imaging layout, and will help to guide downstream analysis. If it was an experiment focused on drought of maize plants and your goal was to get information about water content of plants you might want to take side-view and top-view images of a single plant with a near-infrared camera.
To run a NIR workflow over a single NIR image there are three required inputs:
In principle, image processing will work on any grayscale image with adjustments if images are well lit and there is appreciable contrast difference between the object of interest and the background. 2. Output directory: If debug mode is set to 'print' output images from each intermediate step are produced. 3. Image of estimated background: Right now this is hardcoded into the workflow (different background at each zoom level) and not implemented as an argument.
import cv2
from plantcv import plantcv as pcv
class options:
def __init__(self):
self.image = "./img/original_image.jpg"
self.debug = "plot"
self.writeimg= False
self.result = "nir_tutorial_results.json"
self.outdir = "." # Store the output to the current directory
# Get options
args = options()
# Set debug to the global parameter
pcv.params.debug = args.debug
# Read image
# Inputs:
# filename - Image file to be read in
# mode - How to read in the image; either 'native' (default), 'rgb', 'gray', or 'csv'
img, path, filename = pcv.readimage(filename=args.image)
# Read in the background image
img_bkgrd, bkgrd_path, bkgrd_filename = pcv.readimage(filename="./img/background_average.jpg")
# Subtract the background image from the image with the plant.
# Inputs:
# gray_img1 - Grayscale image data from which gray_img2 will be subtracted
# gray_img2 - Grayscale image data which will be subtracted from gray_img1
bkg_sub_img = pcv.image_subtract(gray_img1=img_bkgrd, gray_img2=img)
# There are often multiple ways to process images. There is also
# a background subtraction function made that creates a binary
# image from performing background subtraction on the foreground
# Inputs:
# foreground_image - RGB or grayscale image data
# background_image - RGB or grayscale image data
fg_mask = pcv.background_subtraction(foreground_image=img, background_image=img_bkgrd)