Blurring an image using the OpenCV function medianBlur()

OpenCVPythonServer Side ProgrammingProgramming

In this program, we will blur the image using the medianBlur() function in the OpenCV library. The median blurring helps to process the edges in an image while removing the noise.

Original Image


Step 1: Import cv2.
Step 2: Read the image.
Step 3: Pass image and kernel size in the cv2.medianblur() function.
Step 4: Display the image.

Example Code

import cv2
image = cv2.imread("testimage.jpg")
image = cv2.medianBlur(image, 7)
cv2.imshow("medianblur", image)


Updated on 17-Mar-2021 08:04:43