使用枕頭庫對圖片應用最大濾鏡


在本程式中,我們將使用枕頭庫對圖片應用最小濾鏡。在最大濾鏡中,圖片中被選中的視窗內每個畫素的值都將替換為該視窗的最大畫素。filter 函式用於利用枕頭庫應用不同的濾鏡。

原圖片

演算法

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

示例程式碼

from PIL import Image, ImageFilter

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

輸出

更新於:18-Mar-2021

387 次瀏覽

開啟您的 職業

完成課程即可獲得認證

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