Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
I'm working on an application that will make an image of a soft drink can, and I want to distort the graphics to simulate 3D perspective (rounded top and bottom). I've got a displacement filter that works in Photoshop, but not in ImageMagick, and I suspect it's because I don't know the correct PerlMagick syntax. It should produce a relatively can-shaped distortion, but for some reason it's skewing on the X-axis:
I know there's a way to define how much to distort on each axis on the command line, and I'm pretty sure I should be setting the X axis to zero, but I can't figure out what the Perl syntax is. Can someone give me an example? Thanks in advance.
anthony wrote:I would be interested to know how you generated that displacement map
I made it in Photoshop, but it wouldn't be difficult to do in ImageMagick. First I made a reflected horizontal gradient, because I wanted more displacement toward the vertical center of the image than at the right and left edges. Then I made a normal vertical gradient, and inverted the first gradient using the second gradient as a mask, so that the displacement would go up at the top of the image and down at the bottom.
Also as the displacement values represents the 'destination' offset, rather than the source offset, (see http://www.imagemagick.org/Usage/compose/#displace ) the 'cosine()' function in the above is distorted by the linear inversion. Making the curve become rather straight toward the edges.
It may be worthwhile to point out that only a specific region of the displacement map is going to get used, corresponding to the label area of the can.
Only the blue region will get distorted. (Actually, a separate graphic the size of the blue region will get distorted, and then composited onto the base can image.)
As I preview this, I realize it would be a better idea to invert the displacement map so that the left and right edges are distorted toward the vertical center, instead of the vertical center being curved up and down - downsampling the edges instead of upsampling the center.