使用 Pillow 庫對影像應用模式濾鏡


我們在這個程式中將使用 Pillow 庫對影像應用最小值濾鏡。在模式濾鏡中,影像選定區域中的每個畫素值都將被此區域的眾數替代。filter 函式用於使用 Pillow 庫應用不同的濾鏡。

原始影像

演算法

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

示例程式碼

from PIL import Image, ImageFilter

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

輸出

更新於: 2021-3-18

193 次瀏覽

開啟你的職業

完成本課程即可獲得認證

開始吧
廣告
© . All rights reserved.