Blurring an Image in Python using ImageFilter Module of Pillow

In this tutorial, we will learn how to blur an image in Python using Pillow. (Also known as PIL)

Blurring an image is nothing but reducing the level of noise in the image and prepare it for further processing, Image blurring is a specific example of applying a filter to an image. The matrix of weight that is used for convolution is called the ‘kernel’ of transformation. Image blurring is an essential part of Image Processing.

There are many modules support by Python that can be used for Image Blurring, but we will be using the ‘ImageFilter’ Module of Pillow. There are three filters or methods in the Image Filter module that can be used for blurring the images, that are:

  • Simple Blur
  • Box Blur
  • Gaussian Blur

All three filters uses ‘Image.filter()’ method for applying the filter to Images.

Simple Blur – In this filter, no external parameter is needed.

Box Blur – In this filter, a parameter is needed that is a ‘radius’ as the radius increases the intensity of blur also increases.

Gaussian Blur – This filter also uses parameter radius and does the same work as in Box Blur just algorithm changes.

Blurring Image using ImageFilter Module in Python


$ pip3 install pillow

Source Code: blur an image in Python

# Import Required Image Module
from PIL import Image
from PIL import ImageFilter

# Open Existing Image
OrgImage ="test.jpg")

# Apply Simple Blur Filter
blurImage = OrgImage.filter(ImageFilter.BLUR)"output1.jpg")

# Apply BoxBlur Filter
boxImage = OrgImage.filter(ImageFilter.BoxBlur(2))"output2.jpg")

# Apply GaussianBlur Filter
gaussImage = OrgImage.filter(ImageFilter.GaussianBlur(2))"output3.jpg")


Original Image:

Blur an Image in Python using Pillow

Simple Blur:

Blur an Image in Python using Pillow

Simple blur

Box Blur:

box blur an image

box blur

Gaussian Blur:

Gaussian Blur in Python

Gaussian Blur

So, I hope this tutorial was fruitful to you, thank you ‘Keep Learning Keep Coding‘.

Also learn:

Leave a Reply

Your email address will not be published. Required fields are marked *