Measure Width of Segments¶
Measure the average width of segments.
plantcv.morphology.segment_width(segmented_img, skel_img, labeled_mask, n_labels=1, label=None)
returns labeled_image
- Parameters:
- segmented_img - Segmented image (output either from
plantcv.morphology.segment_skeletonorplantcv.morphology.segment_id), used for creating the labeled image. - Skeleton image (output from
plantcv.morphology.skeletonizeor output fromplantcv.morphology.prune) - labeled_mask - Labeled mask of segments/objects to get analyzes (output from
plantcv.morphology.fill_segments,pcv.create_labels, orpcv.roi.filter) - label - Optional label parameter, modifies the variable name of observations recorded. (default =
pcv.params.sample_label)
- segmented_img - Segmented image (output either from
- Context:
- Calculates the average width of each segment with a distance transformation.
- Output data stored: Data ('segment_width') automatically gets stored to the
Outputsclass when this function is ran. Width measurements can be scaled to real world units (e.g. mm) using theunit,px_height, andpx_widthparameters. These data can always get accessed during a workflow (example below). For more detail about data output see Summary of Output Observations
Reference Image: Images of copper wires with various diameters for validating root image analysis

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 = "wire"
labeled_img = pcv.morphology.segment_width(segmented_img=segmented_img, skel_img=skel, labeled_mask=labeled_mask, n_labels=5)
# Access data stored out from segment_width
seg_widths = pcv.outputs.observations['wire']['mean_segment_width']['value']
Labeled Image

Source Code: Here