Sort Segments

Sort segments from a skeletonized image into two categories: leaf objects and other objects.

plantcv.morphology.segment_sort(skel_img, objects, mask=None, first_stem=True)

returns Secondary objects, primary objects

  • Parameters:
  • Context:
    • Sorts skeleton segments into two categories: primary and secondary segments. Segments get classified as primary if both end points of the segment coincide with branch points. Segments get classified as secondary if at least one of their endpoints coincide with a tip. By this classification method in the example below primary segments are stem and secondary segments are leaves. Secondary segments get colored green and primary segments get colored fuschia.

Reference Images



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"

# Adjust line thickness with the global line thickness parameter (default = 5)
pcv.params.line_thickness = 3 

leaf_obj, other_obj = pcv.morphology.segment_sort(skel_img=skeleton,

leaf_obj, other_obj = pcv.morphology.segment_sort(skel_img=skeleton,

Segmented Image without Mask


Segmented Image with Mask