Binary Threshold

Creates a binary image from a gray image based on the threshold values. The object target can be specified as dark or light.

plantcv.threshold.binary(gray_img, threshold, max_value, object_type="light")

returns thresholded/binary image

Original image

Screenshot

Grayscale image (saturation channel)

Screenshot

from plantcv import plantcv as pcv

# Set global debug behavior to None (default), "print" (to file), or "plot" (Jupyter Notebooks or X11)

pcv.params.debug = "print"

# Create binary image from a gray image based on threshold values. Targeting light objects in the image.
threshold_light = pcv.threshold.binary(gray_img, 36, 255, 'light')

Thresholded image

Screenshot

from plantcv import plantcv as pcv

# Set global debug behavior to None (default), "print" (to file), or "plot" (Jupyter Notebooks or X11)

pcv.params.debug = "print"

# Create binary image from a gray image based on threshold values. Targeting dark objects in the image.
threshold_dark = pcv.threshold.binary(gray_img, 36, 255, 'dark')

Thresholded image (inverse)

Screenshot