The challenge is already solved, within the Leptonica source code
downloadable from that same site. Look at bilinearXformCoeffs() in
bilinear.c, which sets up the matrix and calls on gaussjordan() in
affine.c for a matrix equation solver.

I ripped out what was needed, assembled a tool for calculating the bilinear 
parameters, and put the result up on my page here:
http://rpresser.googlepages.com/bilineartransformationcoordinates

On 6/18/07, Anthony Thyssen <[EMAIL PROTECTED]> wrote:
"=?ISO-8859-1?Q?Alberto_Sim=F5es?=" on  wrote...
| Hi
|
| I am trying to modify an image putting it in a perspective-like
| position, like this:
|
|
|   |\
|   |  \
|   |    \
|   |     |
|   |     |
|   |    /
|   |  /
|   |/
|
| I tried to use the -affine option, with a matrix I got with
| 'transform' tool on gimp, but I couldn't get this type of
| modification.
|
| Does anybody can help me with this?
| Thank you
| Alberto
|
"Alberto Simões" <[EMAIL PROTECTED]> wrote...
| Briefly, perspective transformation is *not* an affine transformation.
| Affine transformations include only scaling, shearing, rotating and
| translating, none of which can alter the ratio of lengths in the way
| that perspective requires.  Therefore the -affine option isn't going
| to cut it.  You have to do heavier lifting using the -fx option, using
| numbers calculated using the perl script on that page (or a similar
| method).

Affine will only do transformations that keep lines straight
and parrellel.  It will not do perspective, or trapaziodial
transformations.

On the other hand the math for trapaziodial transformations
(lines kept straight, but may no longer be parrellel) is
well understood.

IM can not do this type of transform directly (yet) but is can do it
using a DIY solution using a  -fx distortion.

All of this was explained (and a perspective example given
in IM examples
  http://www.imagemagick.org/Usage/distorts/

I have recently discovered a different type of perspective
transformation, The Bilinear Transform.  It does not keep line
perfectally straight, BUT does not require a slow division either,
making it more appropriate to matrix type of calculations.

See Leptonica, Affine transformations (and cousins)
  http://www.leptonica.com/affine.html

      x' = a*x + b*y + c*x*y + d
      y' = e*x + f*y + g*x*y + h

producing a 4x2 matrix

   x' y'] = [x y xy 1]T

        | a  e |
   T =  | b  f |
        | c  g |
        | d  h |

A DIY -fx solution for this type of perspective is quite straight forward
however what is still needed is a way to generate the 8 constants from
the pre-positioning of 4 coordinates (16 numbers).

Anyone up to the challenge?


  Anthony Thyssen ( System Programmer )    <[EMAIL PROTECTED]>
-----------------------------------------------------------------------------
    SPACE FOR THIS INSERTION IS DONATED BY THE PUBLISHERS AS
    A SERVICE TO THE COMMUNITY      -- John Brunner - "The Sheep Look Up"
-----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users


_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to