Blurring an image using the OpenCV function medianBlur()


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

Algorithm

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)

Output

Updated on: 17-Mar-2021

214 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements