ในโปรแกรมนี้ เราจะใช้ฟิลเตอร์ขั้นต่ำกับรูปภาพโดยใช้คลังหมอน ในการกรองค่ามัธยฐาน ค่าของแต่ละพิกเซลในหน้าต่างที่เลือกของรูปภาพจะถูกแทนที่ด้วยค่ามัธยฐานของหน้าต่างนั้น ฟังก์ชันตัวกรองใช้เพื่อใช้ฟิลเตอร์ต่างๆ โดยใช้คลังหมอน
ภาพต้นฉบับ

อัลกอริทึม
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.
โค้ดตัวอย่าง
from PIL import Image, ImageFilter
im = Image.open('testimage.jpg')
im1 = im.filter(ImageFilter.MedianFilter(size = 7))
im1.show() ผลลัพธ์
