Python – Wand 中的 motion_blur()
我们可以在 Wand 中执行的另一种模糊是Motion Blur 。在这种类型中,高斯模糊是在单个线性方向上执行的,并且看起来像图像在线性方向上移动。它需要一个新的角度参数。
Syntax :
Python3
Python3
Python3
# 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.motion_blur(radius = 22, sigma = 10, angle = 45)
# save final image
img.save(filename ="gb_koala.jpeg")
# display final image
display(img)
Parameter :
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 |
angle | number.Real | Apply the effect along this angle. |
channel | basestring | Optional color channel to apply blur. |
使用的图像:
示例 1:
Python3
wand.image.motion_blur(radius= radius_value, sigma= sigma_value,
angle= angle_value, channel = "optional_channel_value")
# radius should always be greater than sigma(standard deviation)
输出 :
示例 2:增加半径、sigma 并将角度更改为 45。
Python3
# 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.motion_blur(radius = 16, sigma = 8, angle = 90)
# save final image
img.save(filename ="mb_koala.jpeg")
# display final image
display(img)
输出 :