Python PIL UnsharpMask()方法
PIL是Python成像库,它为Python解释器提供了图像编辑功能。ImageFilter模块包含了一组预定义的过滤器的定义,可以用Image.filter()方法来使用。
PIL.ImageFilter.UnsharpMask()方法将Unsahrp蒙版过滤器应用于输入图像。
语法: PIl.ImageFilter.UnsharpMask(radius=2, percent=150, threshold=3)
参数:
半径: 模糊半径
百分比:非锐化强度,百分比
阈值: 阈值控制将被锐化的最小亮度变化。
使用的图片:
# Importing Image and ImageFilter module from PIL package
from PIL import Image, ImageFilter
# creating a image object
im1 = Image.open(r"C:\Users\sadow984\Desktop\download2.JPG")
# applying the unsharpmask method
im2 = im1.filter(ImageFilter.UnsharpMask(radius = 3, percent = 200, threshold = 5))
im2.show()
输出:
# Importing Image and ImageFilter module from PIL package
from PIL import Image, ImageFilter
# creating a image object
im1 = Image.open(r"C:\Users\sadow984\Desktop\download2.JPG")
# applying the unsharpmask method
im2 = im1.filter(ImageFilter.UnsharpMask(radius = 4, percent = 500, threshold = 8))
im2.show()
输出:
# Importing Image and ImageFilter module from PIL package
from PIL import Image, ImageFilter
# creating a image object
im1 = Image.open(r"C:\Users\sadow984\Desktop\download2.JPG")
# applying the unsharpmask method
im2 = im1.filter(ImageFilter.UnsharpMask(radius = 5, percent = 500, threshold = 10))
im2.show()
输出: