PIL是Python Imaging Library,它為python解釋器提供了圖像編輯函數。 ImageFilter模塊包含一組預定義的過濾器的定義,這些定義可與
Image.filter()
方法。PIL.ImageFilter.BoxBlur()
通過將每個像素設置為在每個方向上延伸半徑像素的方框中的像素平均值來模糊圖像。支持任意大小的浮點半徑。使用優化的實現,該實現對於任何半徑值都相對於圖像大小以線性時間運行。
Synatx: PIL.ImageFilter.BoxBlur() Partameters: radius: Size of the box in one direction. Radius 0 does not blur, returns an identical image. Radius 1 takes 1 pixel in each direction, i.e. 9 pixels in total.
使用的圖片:
# 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 boxblur method
im2 = im1.filter(ImageFilter.BoxBlur(0))
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 boxblur method
im2 = im1.filter(ImageFilter.BoxBlur(2))
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 boxblur method
im2 = im1.filter(ImageFilter.BoxBlur(8))
im2.show()
輸出:
相關用法
- Python set()用法及代碼示例
- Python next()用法及代碼示例
- Python os.dup()用法及代碼示例
- Python Method Overloading用法及代碼示例
- Python sympy RGS用法及代碼示例
- Python sympy.crt()用法及代碼示例
- Python os.getcwdb()用法及代碼示例
- Python os.getgroups()用法及代碼示例
- Python sympy.Mod()用法及代碼示例
- Python sympy.gcd()用法及代碼示例
- Python sympy.nP()用法及代碼示例
- Python sympy.lcm()用法及代碼示例
- Python PyTorch sin()用法及代碼示例
- Python sys.getrecursionlimit()用法及代碼示例
注:本文由純淨天空篩選整理自ravikishor大神的英文原創作品 Python PIL | BoxBlur() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。