使用 Pillow 庫在影像上應用中值濾波器


在此程式中,我們將使用 pillow 庫對影像應用最小值濾波器。在中值濾波中,影像中所選視窗中每個畫素的值都將替換為該視窗的中值。filter 函式用於使用 pillow 庫應用不同的濾波器。

原始影像

演算法

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()

輸出

更新於:18-Mar-2021

830 次檢視

開啟你的 職業生涯

完成課程即可獲得認證

開始學習
廣告
© . All rights reserved.