Otsu Threshold

Creates a binary image from a gray image based on the threshold values.

otsu_auto_threshold(img, maxValue, object_type, device, debug=None)

returns device, thresholded image

Grayscale image (green-magenta 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.otsu_auto_threshold(img, 255, 'dark', device, debug="print")

Thresholded image

Screenshot

Grayscale image (blue-yellow channel)

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.otsu_auto_threshold(img1, 255, 'light', device, debug="print")

Thresholded image (inverse)

Screenshot