Page 1 of 1

Mesh/grid warping: Can it be done in IM?

Posted: 2013-09-06T10:17:01-07:00
by Ammit
So searching old posts I can see that as of 2009 it was not possible to do rectangular grid warping in IM but that it was on the "wish list" of things to add. Is it possible at this time or are triangular solutions like Fred's meshwarp still the only viable option?

Thanks

Re: Mesh/grid warping: Can it be done in IM?

Posted: 2013-09-06T10:31:13-07:00
by snibgo

Re: Mesh/grid warping: Can it be done in IM?

Posted: 2013-09-06T11:12:14-07:00
by Ammit
Shepards was my first thought. I thought for sure it would do what I wanted but when I actually played with it I could not get it to do what I needed. I need to take a rectangular image and warp it and stretch it so that it can fit a UV map for a 3D image (specifically an unwrapped model of a horse which looks like a skin rug). Not really sure how to explain why/how Shepards was not working for me but I found that it warped the whole image just like Photoshops Free Transform: Warp tool. What what I am looking for is something more like Photoshops liquify tool or Fred's Meshwarp(http://www.fmwconcepts.com/imagemagick/ ... /index.php) only much more pronounced then his hamster example.

It is totally possible that I have misused Shepards though. Is that the method that was added to create true grid warping?

Re: Mesh/grid warping: Can it be done in IM?

Posted: 2013-09-06T11:25:00-07:00
by fmw42
There is no meshwarp in IM, yet, besides my script. Shepards warp does an inverse distance weighting average. It is not a meshwarp.

Re: Mesh/grid warping: Can it be done in IM?

Posted: 2013-09-06T11:44:53-07:00
by snibgo
shepards:power may be useful: http://www.imagemagick.org/Usage/distor ... ards_power

For mesh warping, I use a generalised barycentric method: include the 4 coners in the point set, triangulate, use barycentric coords to create a displacement map, and use that. It takes a fair bit of C-code to do this, but it is fast. Sadly not (yet) built in to IM.

Re: Mesh/grid warping: Can it be done in IM?

Posted: 2013-09-06T13:44:58-07:00
by fmw42
snibgo wrote:shepards:power may be useful: http://www.imagemagick.org/Usage/distor ... ards_power

For mesh warping, I use a generalised barycentric method: include the 4 coners in the point set, triangulate, use barycentric coords to create a displacement map, and use that. It takes a fair bit of C-code to do this, but it is fast. Sadly not (yet) built in to IM.
That is pretty much what I did in my script, though not very fast.

Re: Mesh/grid warping: Can it be done in IM?

Posted: 2013-09-07T07:05:12-07:00
by Ammit
Thanks for the replies I appreciate it. That is pretty much what I figured. I will look more into barycentric/affine systems. :D