How to blur image in OpenCV Python

You can blur an image in OpenCV Python by any of the given methods. I highly recommend you get the “Computer Vision: Models, Learning, and Inference Book” to learn Computer Vision.

How to blur an image in OpenCV Python
How to blur an image in OpenCV Python

Method 1: Averaging

import cv2

img = cv2.imread('baby.jpg')

Simple_blur = cv2.blur(img,(10,10))

cv2.imshow("Original Image",img)
cv2.imshow('Simple blurring',Simple_blur)

cv2.waitKey(0)
cv2.destroyAllWindows()
Original Image
Original Image
Simple blur
Simple blurring

Method 2: Gaussian Blurring

import cv2

img = cv2.imread('baby.jpg')

gaussian_Blur = cv2.GaussianBlur(img, (5,5),0)

cv2.imshow("Original Image",img)
cv2.imshow('Gaussian Blurring', gaussian_Blur)

cv2.waitKey(0)
cv2.destroyAllWindows()
Gaussian Blur
Gaussian Blurring

Method 3: Median Blurring

import cv2

img = cv2.imread('baby.jpg')

median_Blur = cv2.medianBlur(img,5)

cv2.imshow("Original Image",img)
cv2.imshow('Median Blurring', median_Blur)

cv2.waitKey(0)
cv2.destroyAllWindows()
Median Blur
Median Blurring

Method 4: Bilateral Filtering

import cv2

img = cv2.imread('baby.jpg')

bilateral_Filter = cv2.bilateralFilter(img,9,75,75)

cv2.imshow("Original Image",img)

cv2.imshow('Bilateral Filtering', bilateral_Filter)

cv2.waitKey(0)
cv2.destroyAllWindows()
Bilateral Filtering Blur
Bilateral Filtering

Leave a Comment

Your email address will not be published.