Python中的魔杖 gaussian_blur()函数
另一种类型的模糊是高斯模糊。高斯模糊与法线的区别在于,高斯模糊是通过使用高斯函数来实现的。简单的任何形式的方程: 称为高斯函数。
Syntax :
wand.image.gaussian_blur(radius="radius_value",
sigma="sigma_value",
channel = "optional_channel_value")
# radius should always be greater than sigma(standard deviation)
Parameters :
Parameter | Input Type | Description |
---|---|---|
radius | numbers.real | the radius of the, in pixels, not counting the center pixel. |
sigma | numbers.real | the standard deviation, in pixels |
channel | basestring | Optional color channel to apply blur. |
Image Used :
Example #1:
# import display() to show final image
from wand.display import display
# import Image from wand.image module
from wand.image import Image
# read file using Image function
with Image(filename ="koala.jpeg") as img:
# perform adaptive blur effect using adaptive_blur() function
img.gaussian_blur(radius = 5, sigma = 4)
# save final image
img.save(filename ="gb_koala.jpeg")
# display final image
display(img)
Output :
Example #2: Reduced radius and sigma
# import display() to show final image
from wand.display import display
# import Image from wand.image module
from wand.image import Image
# read file using Image function
with Image(filename ="koala.jpeg") as img:
# perform adaptive blur effect using adaptive_blur() function
img.gaussian_blur(radius = 2, sigma = 3)
# save final image
img.save(filename ="gb_koala.jpeg")
# display final image
display(img)
Output :
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.