使用 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.