使用 Pillow 在影像中尋找邊緣


在這個程式中,我們將使用 pillow 庫來查詢影像中的邊緣。ImageFilter 類中的 FIND_EDGES 函式可以幫助我們在影像中找到邊緣。

原始影像

演算法

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

示例程式碼

from PIL import Image, ImageFilter

im = Image.open('testimage.jpg')
im = im.filter(ImageFilter.FIND_EDGES)
im.show()

輸出

更新於: 2021 年 3 月 17 日

1K+ 瀏覽次數

開啟你的職業生涯

完成課程並獲得認證

開始
廣告
© . All rights reserved.