From 34dc3c657c861e2f07acbb6518ef86ecead269b9 Mon Sep 17 00:00:00 2001 From: Cedric Porter Date: Thu, 26 Jul 2012 21:45:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=8C=E6=99=AF=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EffectLab/Effect.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/EffectLab/Effect.py b/EffectLab/Effect.py index ad5370b..22114af 100755 --- a/EffectLab/Effect.py +++ b/EffectLab/Effect.py @@ -59,8 +59,19 @@ def filter(self, im): mat = cv.CreateMat(3, 3, cv.CV_32FC1) cv.GetPerspectiveTransform(pos, orig, mat) a = numpy.asarray(mat) - - im = im.transform(im.size, Image.PERSPECTIVE, a.flatten(), Image.BILINEAR) + matrix = a.flatten() + + # fill empty color + data = im.transform(im.size, Image.PERSPECTIVE, matrix, + Image.BILINEAR, 1) + mask = Image.new("L", im.size, 255) + mask = mask.transform(im.size, Image.PERSPECTIVE, matrix, + Image.BILINEAR, 1) + imout = Image.new("RGB", im.size, self.empty_color) + imout.paste(data, mask) + + im = imout + return im