Skip to content

Commit

Permalink
背景色
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricporter committed Jul 26, 2012
1 parent 95d2c8d commit 34dc3c6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions EffectLab/Effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 34dc3c6

Please sign in to comment.