📜  Python PIL | UnsharpMask() 方法

📅  最后修改于: 2022-05-13 01:55:15.699000             🧑  作者: Mango

Python PIL | UnsharpMask() 方法

PIL 是Python Imaging Library,它为Python解释器提供了图像编辑功能。 ImageFilter 模块包含一组预定义过滤器的定义,可与 Image.filter() 方法一起使用。
PIL.ImageFilter.UnsharpMask()方法将 Unsahrp 掩码过滤器应用于输入图像。

有关参数的说明,请参阅此数字锐化掩蔽
使用的图像:


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()

输出: