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. For example, if the goal of the project is to quantify the growth rates of a population of Arabidopsis plants, you may want to take timelapse images of whole flats of plants with an RGB (VIS) camera.
To run a VIS workflow over a single VIS image there are two required inputs:
Image processing will work with adjustments if images are well lit and free of background that is similar in color to plant material.
2. Output directory: If debug mode is set to 'print' output images from each step are produced.
import cv2
from plantcv import plantcv as pcv
class options:
def __init__(self):
self.image = "./img/thermal_data.csv"
self.debug = "plot"
self.writeimg= False
self.result = "thermal_tutorial_results.txt"
self.outdir = "."
# 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'
thermal_data, path, filename = pcv.readimage(filename=args.image, mode='csv')
# Rescale the thermal data to a colorspace with range 0-255 rather than raw data
# Inputs:
# gray_img - Grayscale image data
# min_value - New minimum value for range of interest. default = 0
# max_value - New maximum value for range of interest. default = 255
scaled_thermal_img = pcv.transform.rescale(gray_img=thermal_data)
# Threshold the thermal data to make a binary mask
# Inputs:
# gray_img - Grayscale image data
# threshold- Threshold value (between 0-255)
# max_value - Value to apply above threshold (255 = white)
# object_type - 'light' (default) or 'dark'. If the object is lighter than the background then standard
# threshold is done. If the object is darker than the background then inverse thresholding is done.
bin_mask = pcv.threshold.binary(gray_img=thermal_data, threshold=35, max_value=255, object_type='dark')
# Identify objects
# Inputs:
# img - RGB or grayscale image data for plotting
# mask - Binary mask used for detecting contours
id_objects, obj_hierarchy = pcv.find_objects(img=scaled_thermal_img, mask=bin_mask)