Applying MedianFilter on an image using Pillow library

PillowPythonServer Side ProgrammingProgramming

In this program, we will apply a minimum filter on an image using the pillow library. In median filtering, the value of each pixel in a selected window of the image is replaced by the median of that window. The filter function is used to apply different filters using the pillow library.

Original Image

Algorithm

Step 1: Import Image from Pillow.
Step 2: Open the image.
Step 3: Call the filter function and specify the median filter.
Step 4: Display the output.

Example Code

from PIL import Image, ImageFilter

im = Image.open('testimage.jpg')
im1 = im.filter(ImageFilter.MedianFilter(size = 7))
im1.show()

Output

raja
Published on 18-Mar-2021 06:58:54
Advertisements