Perspective warp in one dimension only

I am looking for a perspective warp that is able to distort an image in a single direction, i.e. gradually changing the scale and positions of objects within the image vertically while maintaining their horizontal scale and position.

The “perspective warp” in Photoshop and similar tools in After Effects such as “corner pin” always move objects both vertically and horizontally.

Here is an example of what I want to achieve:

enter image description here

Note how the vertical grid lines are not moved in the desired outcome.

Is there any way to achieve this in tools like Photoshop, Illustrator, After Effects, or Gimp?

I should clarify that my example is not specifically what I want to achieve but merely a demonstrational image. I want to be able to do this with any image without getting the “displacement” that the usual perspective warp brings.

Answer

I assume you want it works with any image, not only with rectangular boxes. The distortion you want is not perspective, you want Y scaling which depends linearly on X. Some programs allow it without having any plugins nor writing a script. The one I know is Affinity Photo. There you can use distortion with equations – you write a formula for coordinates from where in the original image pixel (x,y) is taken to the distorted image.

This is my original:

enter image description here

It’s 1100 pixels wide and 400 pixels high. I placed it to start from x=0, y=0 (that’s the top left corner) to have easy formulas with no offsets.

One distortion example:

enter image description here

pixel (x,y) is taken from the original image coordinates

(x, y/(1-x/2200))

Example 2:

enter image description here

pixel (x,y) is taken from the original image coordinates

(x, y/(1+x/1100))

The shown formulas are quite elementary, but Photoshop and GIMP do not have a way to use them without plugins or scripts. Unfortunately I’m not a programmer, but someone surely knows how to program them as a script.

Using add-on “G’MIC filter pack”

G’MIC is available for GIMP, Photoshop, Krita and Paint.NET. It has image mapping with math formulas at least in the deformation category filters. There are “Cartesian transform” and “Conformal mapping”. The first one uses x and y formulas. The latter leans on complex numbers, so the wanted function at least needs some not so obvious math. At least name “Conformal” hints it’s not designed to give results you want – conformal means keeping angles at least locally. Check this if you are familiar with math functions https://gmic.eu/reference/mathematical_expressions.html#top

G’MIC Command line version users with math and programming knowledge may see easily how to use these effectively. I skip further guessing.

A couple of tests revealed that Cartesian transform can do the same as Affinity Photo’s Distort with Equations. An example:

enter image description here

Point (x,y) in the distorted image is taken from (x, y(1-x/(2w)). Parameters w and h present the width and height of the image in pixels.

Illustrator‘s Envelope Distortion with 1×1 mesh could be used. The idea is already said in general form by user Julian Steinman. But I want to add that Envelope Distortion works as well with vectors and raster images.

As said it can be tiresome to get it right, even with 1×1 mesh. But you can release the envelope distortion and use the same mesh for other images by applying Envelope Distortion > Make with Top Object. The mesh can be stretched to new size for a new image and it still works.

Attribution
Source : Link , Question Author : Zoom , Answer Author : user287001

Leave a Comment