0

Theoretically, I know that to warp an image, each pixel (x,y) in the source image is transformed to (x', y') using a function f (i.e. x'=f(x,y) & y'=f(x,y)). But what mathematical equations can I use instead of the function f().

For example, I found in a website the following for warping an image:

X' = X + [sin(aX) + cos(cY)] . d where a,b,c and d random values.

y'= the same above

My question: from where such this equation come? Is there any systematic technique to generate such equations and then get the similar warped image below?

warped image

Another question How to make a wave warp effect in shader? is asking about the simple wave effect, which is completely different from my question. My question is about how to build equations that represent mapping functions in other complicated warping effects, definitely not simple one like wave equation, and after that how to determine the coefficients “parameters” (a,b,c and d) for these mathematical equations, not by trial and error

Community
  • 1
  • 1
alg
  • 11
  • 3
  • Math.SE is a better place for this if you seek math assistance – Andrew Li Jun 29 '16 at 17:11
  • 1
    The equation comes from you. That is, you write the function that transforms the points. There is a systematic technique to generate the equations. To get something similar to the image you linked, you'd have to experiment. From the looks of things it moves pixels to the left and down or right and down, depending on their horizontal distance from the center of the half of the image they're in. You'll have to experiment to find the exact formula used. – Jim Mischel Jun 29 '16 at 18:19
  • 2
    Fundamentally they shift regions of pixels _smoothly_, that is, the displacement distribution of pixels varies continuously across the image, and does not 'jump' - which would lead to tearing –  Jun 29 '16 at 21:19
  • 1
    Possible duplicate of [How to make a wave warp effect in shader?](http://stackoverflow.com/questions/36174431/how-to-make-a-wave-warp-effect-in-shader) – Spektre Jun 30 '16 at 06:40

1 Answers1

0

I'm sorry to tell you that there is no secret method to do that. You simply think about what you want and then translate that into maths.

That guy who did the wave effect wanted a wave effect, formulated it as a function and transformed the image with it.

Of course you will apply the same techniques here and there and build those transformations from some standard bricks with parameters here and there.

Maybe this helps (google is your friend) http://groups.csail.mit.edu/graphics/classes/CompPhoto06/html/lecturenotes/14_WarpMorph_6.pdf Its about spline interpolation for similar effects to maintain a smooth image.

Piglet
  • 27,501
  • 3
  • 20
  • 43