Page 1 of 1

non-linear scaling

Posted: 2018-12-21T17:40:28-07:00
by josephs
Hi all.

I would like to apply a non-linear scaling to an image with image edge as center point.

To illustrate what I am trying to achieve, I have manually created an input and output file in Photoshop. I have used a a grid to help visualize, but the effect will be applied to photos. Basically, the stretching should progressively increase from top of image to bottom of image. There should be no virtual pixels because the bottom and top edge remain fixed.

https://drive.google.com/file/d/16C_w5_ ... sp=sharing
https://drive.google.com/file/d/1YDsvVO ... sp=sharing

Thus far I have been going the route of displacement maps using simple gradient but that squeezes the image from both ends - not in one direction. If any one could lead me in the right direction it would be appreciated.

Thanks.

Re: non-linear scaling

Posted: 2018-12-21T18:19:04-07:00
by GeeMack
josephs wrote: 2018-12-21T17:40:28-07:00Thus far I have been going the route of displacement maps using simple gradient but that squeezes the image from both ends - not in one direction. If any one could lead me in the right direction it would be appreciated.
There was a discussion on that issue just a couple months ago. You may find some helpful pointers at THIS link. Several methods are described, and there's a link to one of Fred's scripts which should accomplish the task.

Re: non-linear scaling

Posted: 2018-12-21T18:25:51-07:00
by snibgo
josephs wrote:...displacement maps using simple gradient but that squeezes the image from both ends - not in one direction
Perhaps you used "-compose Displace", which is for relative displacement maps, not absolute displacement maps.

This seems very close (identical?) to what you want:

Code: Select all

%IMG7%magick ^
  checks.png ^
  ( +clone ^
    -sparse-color Bilinear ^
0,0,#008,^
%%[fx:w-1],0,#f08,^
0,%%[fx:h-1],#0f8,^
%%[fx:w-1],%%[fx:h-1],#ff8 ^
  -channel G -evaluate Pow 0.5 +channel ^
  ) ^
  -compose Distort -composite ^
  out.png
It creates an identity absolute distortion map, then distorts the green channel, which controls vertical movement. We can use any function. We need a function that maps 0=>0, 1=>1 and 0.5=>about 0.7.

Re: non-linear scaling

Posted: 2018-12-21T18:36:05-07:00
by josephs
Yes. Exactly what I was looking for. Thanks for your help! I was nowhere close to this.