# Apply distortion to Bézier surface

I am trying to simulate the image warp effect, that is used in Adobe Photoshop.

The rectangular image is warped according to a cubic Bézier surface (in 2D, all Z components are 0). Having any Bézier surface, vertical distortion $d \in[0,1]$ can be applied to it.

Left: input bézier surface, $d=0$, Right: output surface, $d=0.8$

Do you have any idea, what is done to the Bézier surface (16 points), when converting from the version on the left to the output on the right?

Edit: changed the answer according to new images and clarification.

for every control point p(k, n)
p'(k, n) = ( p(k, n) - p(k) ) * d * l(k) + p(k, n)


where k is the row index and n is the column index of control point. l is the elevation factor and is equal to {-1, -1/3, 1/3, 1}. p(k) is the center of the k'th row.

Rationale:

From the new images, red and blue lines are drawn from the center of the line (p(k) which is basically (k, 0)) to that point. On the first line, all control points, including the ones on the graph (red lines) are moved to the same point on that line. p(k, n) - p(k) gives the vector which moves a point from p(k) to p(k, n) which now should be applied to the other way, moving the point to the desired location. On your graphs, d = 1 so that all first line points would be moved to the center. You can easily solve the equation to verify this. d * l(0) is -1, so it would be -p(k, n) + p(k) + p(k, n) which would give p(k).

On the second line, your blue line is again from point to the center, but this time it stopped before reaching it. I cannot tell if it really is cut from 1/3 but that would be a good starting point. So the same formula still applies. l is -1/3 d is 1, so the point would be moved in 1/3 of the way. 3rd is the same as the second but it now moves outwards, thus l is 1/3.

On the final line, all control points are moved out from the center point of that line. This is quite clear since your lines meet up at that center.

The only problem this formula can have is assumption of 1/3, other than that I do not see the reason why it should fail.

Note: I used row, column while indexing, thus if you are using x, y you should switch their locations.

• It prserves vertical lines, that is true. But I am working wit Bézier surface (16 points in a plane) and I believe it must be doable just by moving these 16 points, without computing points on bézier curves etc. Here you can see, how Bézier surface works: philipandrews.org/sandbox/BezierSurface/bin/BezierSurface.swf Jul 19, 2016 at 15:02
• I think I found solution to that problem if I understood is correctly. You are asking how to deform bezier surface A to bezier surface B or C to D with d parameter being 0.8, is it correct? Jul 19, 2016 at 15:22
• Well it seems that is not the exact formula but quite close. I will ponder on this a little more. Formula is correct at least for on-the-curve-points. Jul 19, 2016 at 15:32
• You are getting closer :) But for the second example, the Y coordinate changes, too. As I mentioned, all points move along the lines, so it is enough to find the new position for d = 1 for each point, then I can interpolate linearly. Jul 19, 2016 at 15:33