PIL Image transform

Ben C spamspam at spam.eggs
Sat Aug 12 04:59:02 EDT 2006


On 2006-08-11, Dean Card <mailer at forums.com> wrote:

[snip]

> thanks for the reply.  I have been able to use the Image.PERSPECTIVE 
> transform via trial and error to get it to work properly for each transform. 
> What I am really looking for I guess is a way to calculate the 8 int tuple 
> to match the perspective change I am going for.  For a given image there may 
> be 5 elements that need to be 'painted' on with perspective.  A database 
> table will include the transform tuples based on the source image.  So, by 
> passing a starting image and a pattern image, the starting image can be 
> covered with.  Perhaps the best way to explain is visually....
>
> http://seanberry.com/perspective.png
>
> What I need to know is how you take a surface like (P1, P5, P6, P2) and 
> describe it with the 8 int tuple?

You could try asking this in comp.graphics.algorithms. The question is
easily made non-Python-specific, just say you have a function in a
library that does this:

Transform each point {x,y} in an image into a new point {x1,y1} where
{x1,y1} = {(ax + by + c)/(gx + hy + 1), (dx + ey + f)/(gx + hy + 1)}

then ask how to choose the params a to h to achieve the effect
illustrated on http://seanberry.com/perspective.png.



More information about the Python-list mailing list