Python PIL的MedianFilter()和ModeFilter()方法
PIL是Python成像库,它为Python解释器提供了图像编辑功能。ImageFilter模块包含了一组预先定义好的过滤器的定义。
这可以与Image.filter()方法一起使用。
PIL.ImageFilter.MedianFilter()方法创建一个中值过滤器。在一个给定大小的窗口中挑选中值像素值。
语法: PIL.ImageFilter.MedianFilter(size=3)
参数:
size: 内核大小,以像素为单位。
使用的图片:
输出:
PIL.ImageFilter.ModeFilter()方法创建一个模式过滤器。在一个给定大小的盒子里挑选出最频繁的像素值。只出现一次或两次的像素值被忽略;如果没有像素值出现两次以上,则保留原来的像素值。
语法: PIL.ImageFilter.ModeFilter(size=3)
参数:
size: 内核大小,以像素为单位。
输出: