Python PIL | UnsharpMask() 方法
PIL 是Python Imaging Library,它为Python解释器提供了图像编辑功能。 ImageFilter 模块包含一组预定义过滤器的定义,可与 Image.filter() 方法一起使用。
PIL.ImageFilter.UnsharpMask()方法将 Unsahrp 掩码过滤器应用于输入图像。
Syntax: PIl.ImageFilter.UnsharpMask(radius=2, percent=150, threshold=3)
Parameters:
radius: Blur Radius
percent: Unsharp strength, in percent
threshold: Threshold controls the minimum brightness change that will be sharpened
有关参数的说明,请参阅此数字锐化掩蔽
使用的图像:
Python3
# 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()
Python3
# 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()
Python3
# 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()
输出:
Python3
# 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()
输出:
Python3
# 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()
输出: