Fill Segments

Propagate the labels of a segmented skeleton to fill the mask.

plantcv.morphology.fill_segments(mask, objects, stem_objects=None, label=None)

returns filled_mask

  • Parameters:
  • Context:
    • Uses the watershed algorithm to fill the mask propagating the objects' labels.
  • Output data stored: Data ('segment_area') automatically gets stored to the Outputs class when this function is ran without the stem_objects parameter. When the optional parameter is utilized then the data variable names will be ('leaf_area') and ('stem_area'). Data sample names are modified with an optional label prefix. These data can always get accessed during a workflow (example below). For more detail about data output see Summary of Output Observations

Reference Image: mask, objects drawn as labels

Screenshot

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 = "plot"
# Optionally, set a sample label name
pcv.params.sample_label = "plant"

filled_mask = pcv.morphology.fill_segments(mask=plant_mask, objects=obj)

# Convert labeled mask to a colorized image
filled_image = pcv.visualize.colorize_label_img(label_img=filled_mask)

# Access data stored out from fill_segments
segments_area = pcv.outputs.observations['plant']['segment_area']['value']

Filled Image

Screenshot

Source Code: Here