Re: Using other applications affine transformation matrixes with Imager
From: Tony Cook (firstname.lastname@example.org)
Date: Sat 07 Nov 2009 - 22:53:39 GMT
Next message: Bernhard Wei▀huhn: "Re: Using other applications affine transformation matrixes with Imager"
It seems the main difference is that Imager uses the matrix to convert
a location in the destination image to a location in the source image,
while ImageMagick uses it to convert a location in the source image to
a location in the destination image.
I expect what you need is the inverse of the matrix you're using with
On Sat, Nov 07, 2009 at 08:03:46PM +0100, Bernhard Wei?huhn wrote:
> being seriously impressed with the performance of Imager, I want to
> convert an application from using Imagemagick's affine transform
> functions to Imagers own matrix_transform().
> Unfortunately, their behaviour is quite different.
> ImageMagick (and Cairo too btw.) use six-coefficient matrices like to:
> [ sx, rx,
> ry, sy,
> tx, ty ]
> ... which i naively converted to Imagers nine coefficient matrix like
> [ sx, rx, tx,
> ry, sy, ty,
> 0, 0, 1 ]
> Unfortunately, it's not that easy. By trial and error I ended up with
> some modifications (1/sx etc), which give better results for easy
> cases, but fail as soon as negative parameters or more complex
> combinations are involved. I suspect a relatively easy mathematical
> transformation of the paramters, but I can't figure it out by myself.
> Can somebody point me in the right direction?
> ImageMagick's matrix transformations are explained in detail here: http://www.imagemagick.org/Usage/distorts/affine/
> Btw: I was supprised to see Cairo working with imagemagicks matrices
> out of the box, but I'd like to avoid my current hack moving image
> data back and forth between Imager and Cairo ImageSurfaces, and would
> rather use Imagers builtin matrix_transform, since it not only seems
> faster, but also prettier.
> Any help greatly appreciated,