How to Blur an Image in Python

Spread the love

In this post, you will learn How to blur an image in python.

Blur an Image –

To blur an Image we can transform each pixel to be the average value of it’s neighbors. In openCV this is done by using a kernel. The size of the kernel determines how much we want to blur an image. Increasing the size will increase the blur of an image.

# load libraries
import cv2
import numpy as np
import matplotlib.pyplot as plt

# load an image 
image = cv2.imread('maldives.jpg', cv2.IMREAD_GRAYSCALE)

# blur image
image_blur = cv2.blur(image, (25, 25))

# show image
plt.imshow(image_blur, cmap="gray")

Rating: 1 out of 5.

Leave a Reply