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