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.

binary_threshold(img, threshold, maxValue, object_type, device, debug=None)

returns device, thresholded image

Original image

Screenshot

Grayscale image (saturation channel)

Screenshot

from plantcv import plantcv as pcv

# Create binary image from a gray image based on threshold values. Targeting light objects in the image.
device, threshold_light = pcv.binary_threshold(img, 36, 255, 'light', device, debug="print")

Thresholded image

Screenshot

from plantcv import plantcv as pcv

# Create binary image from a gray image based on threshold values. Targeting dark objects in the image.
device, threshold_dark = pcv.binary_threshold(img, 36, 255, 'dark', device, debug="print")

Thresholded image (inverse)

Screenshot