2012-03-14 109 views
4

我无法理解如何将模糊滤镜应用于使用PIL的图像的一部分。 我试着用google搜索并阅读PIL文档,但没有找到有用的东西。 感谢您的帮助。使用PIL过滤部分图像,python

+0

我试图裁剪图像并应用过滤器的一部分。 但我相信有更简单和正确的方法。 – 2012-03-14 12:05:36

+3

你可以发布你如何裁剪图像的代码,并试图应用过滤器。如果我们不知道你目前的做事方式是什么,那么我们很难提出更简单更正确的方法。 – BioGeek 2012-03-14 12:17:33

回答

13

您可以剪裁出的图像的一部分,对其进行模糊处理,并坚持它放回这样的:

box = (30, 30, 110, 110) 
ic = image.crop(box) 
for i in range(10): # with the BLUR filter, you can blur a few times to get the effect you're seeking 
    ic = ic.filter(ImageFilter.BLUR) 
image.paste(ic, box) 

enter image description here