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

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Ammit
Posts: 3
Joined: 2013-09-05T06:33:54-07:00
Authentication code: 6789

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

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo »

snibgo's IM pages: im.snibgo.com
Ammit
Posts: 3
Joined: 2013-09-05T06:33:54-07:00
Authentication code: 6789

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

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
Ammit
Posts: 3
Joined: 2013-09-05T06:33:54-07:00
Authentication code: 6789

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

Post 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
Post Reply