Filter a Mask using a Region of Interest¶
Filter objects (connected regions of non-zero pixels) within a region of interest. This function is similar to
plantcv.roi.filter but is faster, though it only supports the partial overlap method
(roi_type='partial'
in plantcv.roi.filter
).
plantcv.roi.quick_filter(mask, roi)
returns filtered_mask
-
Parameters:
- mask = binary image data to be filtered
- roi = region of interest, an instance of the Objects class, output from one of the pcv.roi subpackage functions
-
Context:
- Used to filter objects within a region of interest and decide which ones to keep.
-
Example use:
- Below
RGB image
Thresholded image (mask)
ROI visualization
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"
# ROI filter keeps objects that are partially inside ROI
filtered_mask = pcv.roi.quick_filter(mask=mask, roi=roi)
Filtered mask
Source Code: Here