- 论坛徽章:
- 0
|
本帖最后由 greatghoul 于 2012-09-21 10:43 编辑
- #-*- coding: utf-8 -*-
- from PIL import Image, ImageFilter
- class MyGaussianBlur(ImageFilter.Filter):
- name = "GaussianBlur"
- def __init__(self, radius=2, bounds=None):
- self.radius = radius
- self.bounds = bounds
- def filter(self, image):
- if self.bounds:
- clips = image.crop(self.bounds).gaussian_blur(self.radius)
- image.paste(clips, self.bounds)
- return image
- else:
- return image.gaussian_blur(self.radius)
- bounds = (150, 130, 280, 230)
- image = Image.open('source.jpg')
- image = image.filter(MyGaussianBlur(radius=29, bounds=bounds))
- image.show()
复制代码 具体见 http://www.g2w.me/2012/09/gaussi ... a-using-python-pil/
|
|