Erode¶
Perform morphological 'erosion' filtering. Keeps pixel in center of the kernel if conditions set in kernel are true, otherwise removes pixel.
plantcv.erode(gray_img, ksize, i, roi=None)
returns image after erosion
-
Parameters:
- gray_img - Grayscale (usually binary) image data
- ksize - Kernel size, an odd integer that is used to build a ksize x ksize matrix using np.ones. Must be greater than 1 to have an effect
- i - An integer for number of iterations, i.e. the number of consecutive filtering passes
- roi - Optional rectangular ROI as returned by
pcv.roi.rectanglewithin which to apply this function. (default = None, which uses the entire image)
-
Context:
- Used to perform morphological erosion filtering. Helps remove isolated noise pixels or remove boundary of objects.
- Example use:
- Below
Input grayscale image

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"
# Perform erosion filtering
# Results in removal of isolated pixels or boundary of object removal
er_img = pcv.erode(gray_img=gray_img, ksize=3, i=1)
Image after erosion

Source Code: Here