本文介绍了如何使用Python枕头定义模糊半径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用枕头模糊图像.readthedocs.io/en/3.2.x/reference/ImageFilter.html"rel =" noreferrer> ImageFilter 如下:

I'm trying to blur an image with Pillow, using the ImageFilter as follows:

from PIL import ImageFilter
blurred_image = im.filter(ImageFilter.BLUR)

这很好,除了它的设定半径对我来说太小了.我想对图像进行太多的模糊处理,以至于几乎无法识别它.在文档中,我看到半径设置为默认情况下为2 ,但是我不太了解如何将其设置为更大的值?

This works fine, except that it has a set radius which is way too small for me. I want to blur the image so much that it can be barely recognised anymore. In the docs I see that the radius is set to 2 by default, but I don't really understand how I can set it to a larger value?

有人知道如何使用Pillow来增加模糊半径吗?欢迎所有提示!

Does anybody have any idea how I could increase the blur radius with Pillow? All tips are welcome!

推荐答案

Image.filter()使用ImageFilter,因此您可以创建具有任意半径的ImageFilter.GaussianBlur实例,并将其作为命名参数传入.

Image.filter() takes an ImageFilter so you can create an ImageFilter.GaussianBlur instance with whatever radius you want, passed in as a named argument.

blurred_image = im.filter(ImageFilter.GaussianBlur(radius=50))

您甚至可以像这样使它更简洁:

You can even make it more concise like so:

blurred_image = im.filter(ImageFilter.GaussianBlur(50))

这篇关于如何使用Python枕头定义模糊半径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 04:10