Perspective skews

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?".
Post Reply
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

The above image has more than just perspective skewing involved. It also has some shading effects to give the image an appropriate 'curvature'.

In IM perspective skewing as you call it is not directly supported, however it is posible using distortion maps to generate the appropriate transfering of the image pixels to the specified positions.

See http://www.cit.gu.edu.au/~anthony/graph ... distortion

After this a third map can be used to darken one part and lighten the 'edge' as well as generate the rounded shade look of the corner, and the 'puffy' look areounf the edges.

All three maps needed (X placement, Y placement and shading) as well as a fourth 'shape mask' to make outline the parts not covered by the distortion, (4 total) are ALL grey scale images, and as such could even be saved as a single 4 channel 'mapping' image.

The trick however is to create each of the 4 maps. X position using a horizontal gradient, Y position using a vertical gradient, shading using a plain grey image and lighting effects, and finally the outline mask using a background. This is a problem, and probably would need the use of a ray tracer to generate them.

But once those 4 maps have been created you can use them as many times as you like on any number of images, and with careful coding any sized image too.

IN Summery. No IM can to this directly. But with work, YES it can be done so that you can generate a batch process to do it to a lot of images.

I myself would love to see it done and work out the code needed for the generation and implimentation of this outlined 4 map technique, and even document it for IM Examples as the ultimate image distortion technique. But I don't have the time to do so.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply