Image perspective with PIL

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Image perspective with PIL

PyProg PyProg
Hello,

I would like to apply an image perspective.

The syntax of PIL in this regard seems to be:

im.transform (self, size, PERSPECTIVE, data = None, resample = 0, fill = 1)

I want to know exactly what to include in data.

Can you give me an example ?.

Thank you in advance.

a +

--
http://ekd.tuxfamily.org
http://ekdm.wordpress.com
http://lprod.org/wiki/doku.php/video:encodage:avchd_converter
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: Image perspective with PIL

Fredrik Lundh
I've added the documentation from the original patch to this page:

  http://effbot.org/tag/pil.Image.Image.transform

The next text is attached below.

</F>

im.transform(size, PERSPECTIVE, data)

im.transform(size, PERSPECTIVE, data, filter)

Applies a perspective transform to the image, and places the result
in a new image with the given size.

Data is a 8-tuple (a, b, c, d, e, f, g, h) which contains the
coefficients for a perspective transform. For each pixel (x, y)
in the output image, the new value is taken from a position
(a x + b y + c)/(g x + h y + 1), (d x + e y + f)/(g x + h y + 1)
in the input image, rounded to nearest pixel.

This function can be used to change the 2D perspective of the
original image.

On Wed, Apr 28, 2010 at 11:59 PM, PyProg PyProg <[hidden email]> wrote:

> Hello,
>
> I would like to apply an image perspective.
>
> The syntax of PIL in this regard seems to be:
>
> im.transform (self, size, PERSPECTIVE, data = None, resample = 0, fill = 1)
>
> I want to know exactly what to include in data.
>
> Can you give me an example ?.
>
> Thank you in advance.
>
> a +
>
> --
> http://ekd.tuxfamily.org
> http://ekdm.wordpress.com
> http://lprod.org/wiki/doku.php/video:encodage:avchd_converter
> _______________________________________________
> Image-SIG maillist  -  [hidden email]
> http://mail.python.org/mailman/listinfo/image-sig
>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: Image perspective with PIL

PyProg PyProg
2010/5/3 Fredrik Lundh <[hidden email]>:

> I've added the documentation from the original patch to this page:
>
>  http://effbot.org/tag/pil.Image.Image.transform
>
> The next text is attached below.
>
> </F>
>
> im.transform(size, PERSPECTIVE, data)
>
> im.transform(size, PERSPECTIVE, data, filter)
>
> Applies a perspective transform to the image, and places the result
> in a new image with the given size.
>
> Data is a 8-tuple (a, b, c, d, e, f, g, h) which contains the
> coefficients for a perspective transform. For each pixel (x, y)
> in the output image, the new value is taken from a position
> (a x + b y + c)/(g x + h y + 1), (d x + e y + f)/(g x + h y + 1)
> in the input image, rounded to nearest pixel.
>
> This function can be used to change the 2D perspective of the
> original image.

Hello

The problem is that I do not understand what that means: "which
Contains the coefficients for a perspective transform ... "... and in
particular what exactly match a, b, c, d, e, f, g and h.

If you are patient (excuse me), can you explain with precision (and a
didactic, for someone who has trouble like me) what these data (and
possibly with an example of processing with good values for a, b, c,
d, e, f , g and h).

Thank you in advance.

a+

--
http://ekd.tuxfamily.org
http://ekdm.wordpress.com
http://lprod.org/wiki/doku.php/video:encodage:avchd_converter
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: Image perspective with PIL

Edward Cannon
a,b,c,d,e,f,g,h are the coefficients of the perspective transform.
look at http://alumni.media.mit.edu/~cwren/interpolator/ for a brief
introduction (look for the fraction formula x= (ax+by+c)/(gx=hy+1)

On Sun, May 16, 2010 at 9:51 AM, PyProg PyProg <[hidden email]> wrote:

> 2010/5/3 Fredrik Lundh <[hidden email]>:
>
>> I've added the documentation from the original patch to this page:
>>
>>  http://effbot.org/tag/pil.Image.Image.transform
>>
>> The next text is attached below.
>>
>> </F>
>>
>> im.transform(size, PERSPECTIVE, data)
>>
>> im.transform(size, PERSPECTIVE, data, filter)
>>
>> Applies a perspective transform to the image, and places the result
>> in a new image with the given size.
>>
>> Data is a 8-tuple (a, b, c, d, e, f, g, h) which contains the
>> coefficients for a perspective transform. For each pixel (x, y)
>> in the output image, the new value is taken from a position
>> (a x + b y + c)/(g x + h y + 1), (d x + e y + f)/(g x + h y + 1)
>> in the input image, rounded to nearest pixel.
>>
>> This function can be used to change the 2D perspective of the
>> original image.
>
> Hello
>
> The problem is that I do not understand what that means: "which
> Contains the coefficients for a perspective transform ... "... and in
> particular what exactly match a, b, c, d, e, f, g and h.
>
> If you are patient (excuse me), can you explain with precision (and a
> didactic, for someone who has trouble like me) what these data (and
> possibly with an example of processing with good values for a, b, c,
> d, e, f , g and h).
>
> Thank you in advance.
>
> a+
>
> --
> http://ekd.tuxfamily.org
> http://ekdm.wordpress.com
> http://lprod.org/wiki/doku.php/video:encodage:avchd_converter
> _______________________________________________
> Image-SIG maillist  -  [hidden email]
> http://mail.python.org/mailman/listinfo/image-sig
>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig