Pillow怎么对图像应用径向模糊效果
要对图像应用径向模糊效果,可以使用Pillow库中的ImageFilter模块。以下是一个示例代码,演示如何在Python中使用Pillow库对图像应用径向模糊效果:
from PIL import Image, ImageFilter# 打开要处理的图像文件image = Image.open('example.jpg')# 应用径向模糊效果blurred_image = image.filter(ImageFilter.GaussianBlur(radius=5))# 保存处理后的图像文件blurred_image.save('blurred_example.jpg')# 显示原始图像和处理后的图像image.show()blurred_image.show()在上面的代码中,首先使用Image.open()方法打开要处理的图像文件。然后,使用filter()方法和ImageFilter.GaussianBlur()函数来应用径向模糊效果,其中radius参数指定了模糊半径。最后,使用save()方法保存处理后的图像文件,并使用show()方法显示原始图像和处理后的图像。
