Page 1 of 1

Perspective Projection Distortion

Posted: 2012-09-09T05:14:48-07:00
by Alan Hadley
I am buissy adding IM functions to my software and am working on Distort now, I am using the IM Core interface.

I tried putting random values in a Perspective Projection Distortion and sometimes I had a crash and sometimes no results at all.

I found that the crash was caused by using -ve values for Px or Py, you can see why if you inspect the equations given on the examples page, division by zero.

I also noticed that the 'shrinking' can only be done in one direction along each axis, so I have decided to make -ve values of Px,Py flip/flop the sourcxe image then flip/flop it back again when the distortion is done, and use abs(Px) and abs(Py) for the distort paramaters.

I noticed that it is easy to Distort an image away, are there any easy sanity checks on values to warn of this or when a distort is impossible?

Alan Hadley

Re: Perspective Projection Distortion

Posted: 2012-09-09T12:57:11-07:00
by fmw42
Distort perspective is impossible if the divisor is zero or if you put a twist into your coordinates (the top right is left of the top left, same for bottom, but only one or the other top or bottom swapped) or if all points fall on a line.

Re: Perspective Projection Distortion

Posted: 2012-09-11T17:14:44-07:00
by anthony
When putting a twist in the perspective distort, the 'sky' or 'missed image' aspect of perspective distortion may suddenly decide you are looking from 'underneath' the distortion, as make it 'disappear' (use 'matte color' instead).

It was added to make it easy to do 'horizon' views, relativeally easy to generate.
See Viewing Distant Horizons
http://www.imagemagick.org/Usage/distorts/#horizon