如何使用 Pillow 庫給影像應用最小化濾波


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

原始影像

演算法

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

示例程式碼

from PIL import Image, ImageFilter

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

輸出

更新時間:2021 年 3 月 18 日

208 次瀏覽

Kickstart Your Career

完成課程即可獲得認證

開始
Advertisement
© . All rights reserved.