Page 1 of 1

Distort Quadrilateral to Quadrilateral

Posted: 2014-04-08T10:22:07-07:00
by josephs
Hi Everyone.

Really stuck here. I am attempting to distort a non-orthogonal quadrilateral to another non-orthogonal quadrilateral. The closest I cam come to achieve this is by using the 'BilinearReverse'...but the output is for orthogonally aligned rectangle so result is not desired. Is ImageMagick able to distort any quadrilateral to any quadrilateral, maintain straight edges. If yes, please lead me in right direction :)

Thanks in advance for any help!

Re: Distort Quadrilateral to Quadrilateral

Posted: 2014-04-08T10:43:42-07:00
by snibgo
"-distort perspective" is probably what you want. See http://www.imagemagick.org/script/comma ... hp#distort

Re: Distort Quadrilateral to Quadrilateral

Posted: 2014-04-08T10:52:56-07:00
by josephs
I have tried distort perspective with unfavorable results. I think its because perspective assumes a rectangular shape as input...I am trying to distort a quadrilateral with vertices anywhere.

Re: Distort Quadrilateral to Quadrilateral

Posted: 2014-04-08T13:18:04-07:00
by snibgo
If you put a sample image somewhere like dropbox.com and paste the URL here, someone might take a look.

Re: Distort Quadrilateral to Quadrilateral

Posted: 2014-04-08T14:40:37-07:00
by josephs
After further research i was able to confirm it is not possible to achieve what I am asking. As noted on in IM documentation: "There are future plans to produce a true Bilinear distortion that will attempt to map any quadrilateral to any other quadrilateral, while preserving edges (and edge distance ratios)."

So for now not possible but its all good because I was able to use existing tools with some creativity to achieve the affect I was looking for (more-or-less anyway).

Re: Distort Quadrilateral to Quadrilateral

Posted: 2014-04-08T15:50:11-07:00
by fmw42
You should be able to do it with a combination of -distort BilinearRevers and -distort BilinearForward, but you will need to pick control points manually for each of the two operations. The result of the first operation should be a rectangle.

Re: Distort Quadrilateral to Quadrilateral

Posted: 2014-04-08T16:29:29-07:00
by josephs
Great solution! Seems so simple can't believe I missed it! Thank you.

Re: Distort Quadrilateral to Quadrilateral

Posted: 2014-04-08T18:04:51-07:00
by anthony
The "True Bilinear" distortion was in reference to doing both halfs of the Bilinear distortion operations simultaneously.

The next stage... Grid Distortion, would require some major re-arrangement of the distortion code, so that multiple distortions can be applied to an image based on which area of the destination image is being worked on. That I am not going to do.