[prev in list] [next in list] [prev in thread] [next in thread] 

List:       imagemagick-user
Subject:    Re: [magick-users] Size of the output image when using the -fx
From:       Anthony Thyssen <anthony () griffith ! edu ! au>
Date:       2006-12-18 7:44:17
Message-ID: 200612180744.kBI7iHYX010655 () wraith ! its ! griffith ! edu ! au
[Download RAW message or body]

Hugemann on  wrote...
| Hi,
| 
| I am still working on the projective transformation of images, see
| http://www.cit.gu.edu.au/~anthony/graphics/imagick6/distorts/#perspective
| 
| One of the problems I meet is that if I want to rectify a complete 
| perspective photograph, the output image usually has not the same size 
| as the input image. By default, the -fx operator creates an output image 
| of the same size as the input image.
| 
| At the moment, I solve this problem by calculating the dimensions of the 
| output image and enlarging the input image as needed by adding a white 
| border.
| 
| Is there a more direct way to handle this?
| 
Unlike the affine matrix transform which endevors to ensure no data is
lost, (and using virtual canavs positions to handle negative offsets),
the -fx transform does not have that luxury.

Handling virtual offsets in source and destination

You will need to forward transform the four corners to find the bounding
rectangle.

Then add the top and left bounds of the pixel being 'lookedup' in
destination image before transforming so the transformed coordinates
match up the source image.  If the source image also has offsets they
will then need to be subtracted before the color is looked up.

Note that you need a forward transform for the bounds and a reverse
transform for the color lookups.

I was planing to demonstrate this with the DIY affine transform, however
because of the recent traffic about these transforms Cristy was going to
look at fixing the builtin affine transform, last weekend.  The next job
after that was a builtin perspective, FX style, transform.

NOTE: IM implements affine transforms as a set of shears, scales and
translates.  Note that -rotate is also implemented as a set of 3 shears.
This is suposed to be faster, that a reverse pixel lookup.

An parsed FX expression is of course extremely slow, so comparisions are
not posible using DIY methods.

I do not know if the new perspective transforms should work in virtual
space or not, but it is relativeally straight forward to implement,
unlike the complex affine internals.   Turning off the virtual canvas
results from the source and destination is still reasonably easy.


  Anthony Thyssen ( System Programmer )    <A.Thyssen@griffith.edu.au>
 -----------------------------------------------------------------------------
 Two hydrogen atoms walk into a bar. One says, "I've lost my electron".
 The other says, "Are you sure?" The first replies, "Yes, I'm positive..."
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/
_______________________________________________
Magick-users mailing list
Magick-users@imagemagick.org
http://studio.imagemagick.org/mailman/listinfo/magick-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic