使用 Pillow 庫對影像應用 Box Blur


在此專案中,我們將使用 Box 濾波器對影像進行模糊處理。pillow 庫中的 ImageFilter 類包含一個名為 BoxBlur() 的函式,該函式有助於應用 Box 模糊濾波器。它只接受一個引數,即模糊半徑。

原始影像

演算法

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.

示例程式碼

from PIL import Image, ImageFilter

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

輸出

更新日期:2021 年 3 月 18 日

347 次瀏覽

開啟您的 職業生涯

完成課程獲得認證

開始
廣告
© . All rights reserved.