使用 Pillow 庫對影像應用高斯模糊


在此程式中,我們將使用高斯濾波器模糊影像。Pillow 庫中的 ImageFilter 類包含一個名為 GaussianBlur() 的函式,該函式有助於應用高斯模糊濾波器。它只接受一個引數,即模糊半徑。

原影像

演算法

Step 1: Import Image and ImageFilter from Pillow.
Step 2: Open the image.
Step 3: Call the gaussianblur() 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.GaussianBlur(radius = 9))
im1.show()

輸出

更新於: 18-Mar-2021

765 次瀏覽

開啟你的 職業

完成課程,獲得認證

立即開始
廣告
© . All rights reserved.