Applying Box Blur to an image using the Pillow library

PillowPythonServer Side ProgrammingProgramming

In this program, we will blur an image using a Box filter. The ImageFilter class in the pillow library contains a function called BoxBlur() which helps to apply the box blur filter. It takes only one parameter that is blur radius.

Original Image

Algorithm

Step 1: Import Image and ImageFilter from Pillow.
Step 2: Open the image.
Step 3: Call the boxblur() method and specify the radius.
Step 4: Display the output.

Example Code

from PIL import Image, ImageFilter

im = Image.open('image_test.jpg')
im1 = im.filter(ImageFilter.BoxBlur(radius = 7))
im1.show()

Output

raja
Published on 18-Mar-2021 07:00:51
Advertisements