Median Blur¶
Applies a median blur filter. Applies median value to central pixel within a kernel size. The function is a wrapper for the SciPy function median filter.
plantcv.median_blur(gray_img, ksize, roi=None)
returns blurred image
- Parameters:
- gray_img - Grayscale image data
- ksize - kernel size => integer or tuple,
ksizexksizebox if integer, (n, m) size box if tuple - 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 reduce image noise
- Example use:
- Below
Thresholded 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"
# Apply median blur to a binary image that has been previously thresholded.
blur_5 = pcv.median_blur(gray_img, 5)
Median blur (ksize = 5)

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"
# Apply median blur to a binary image that has been previously thresholded.
blur_11 = pcv.median_blur(gray_img, (11, 11))
Median blur (ksize = (11,11))

Source Code: Here