How to do Perspective Projection Distortion ?

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
kehlh
Posts: 2
Joined: 2013-05-06T14:16:18-07:00
Authentication code: 6789

How to do Perspective Projection Distortion ?

Post by kehlh » 2013-05-06T15:02:16-07:00

Hi,
I have Perlmagick / Imagemagick 6.7.7.10-5 installed on my Raspberry Pi.
I want to do a perspective projection distortion, basically taking the upper two points of the image and shift them out on x-axis further left (-15) and right (+8).
I understood from the docu ( http://www.imagemagick.org/Usage/distorts/ ) that there are two ways to do this, either providing the coordinates for the 4 points and use distort perspective method or use the Perspective Projection Distortion and providing the matrix coefficents. I tried both methods on http://www.imagemagick.org/MagickStudio ... Studio.cgi and it works as it should with following parameters:
distort perspective with params: 0,0, -15,0, 0,59, 0,59, 281,59, 281,59, 281,0, 287,0 or
distort perspective projection with params: 1.06649, 0.25, -15 0, 1.06649, 0 0, 0.00111

Now the problems: perspective projection distort seems to be not existing in PerlMagick, at least it is not mentioned in the API description. Or is this a version problem and it was not there in 6.7.7 ? If it is existing undocumented in PerlMagick, what is the syntax to use it ?

When I try to do the normal perspective distort with the points it does not work either:
$image2->Distort('virtual-pixel'=>'transparent', type=>'Perspective', points=>[0,0,-15,0,0,59,0,59,281,59,281,59,281,0,287,0]);

perl: magick/distort.c:498: GenerateCoefficients: Assertion `! "Unknown Method Given"' failed.
Aborted

Any hints ?
Thank you
Best Regards
kehlh

kehlh
Posts: 2
Joined: 2013-05-06T14:16:18-07:00
Authentication code: 6789

Re: How to do Perspective Projection Distortion ?

Post by kehlh » 2013-05-21T06:31:54-07:00

Hi,
In the meantime I found a workaround by doing a system call to use Imagemagick from Perl like this.

$command = "convert $inputfile -matte -virtual-pixel transparent -distort perspective '0,0,-15,0,0,59,0,59,281,59,281,59,281,0,287,0' ".$outputfile;
$return_code = system($command);

But I still would be interested how I can do this in perlMagick directly, or is this a bug or not yet suppored feature of PerlMagick.

Thanks for your help
kehlh

Post Reply