Image Warping - Bulge Effect Algorithm
12,806
Solution 1
See if I understood what you want. Suppose your image coordinates go from 0 to 1.
If you do:
r = Sqrt[(x - .5)^2 + (y - .5)^2]
a = ArcTan[x - .5, y - .5]
rn = r^2.5/.5
And then remap your pixels according to:
x -> rn*Cos[a] + .5
y -> rn*Sin[a] + .5
You get:
You may adjust the parameters to get bigger or smaller bulges.
Edit
Let's see if I understood your comment about warping. The following images are generated using
rn = r^k {k: 1 ... 2}:
Solution 2
GLSL code version:
uniform sampler2D tex;
void main()
{
vec2 cen = vec2(0.5,0.5) - gl_TexCoord[0].xy;
vec2 mcen = - // delete minus for implosion effect
0.07*log(length(cen))*normalize(cen);
gl_FragColor = texture2D(tex, gl_TexCoord[0].xy+mcen);
}
original:
explosion:
implosion:
cheers!
Related videos on Youtube
Author by
random
Updated on October 21, 2020Comments
-
random over 3 years
Can any point to image warping algorithms? Specifically for bulge effect?
-
YoungDev over 2 yearsMay you help me with this? stackoverflow.com/questions/70683954/how-can-i-do-image-warp
-
-
sedavidw over 13 yearsYou don't really need to go into trigonometry.
Cos[a] = (x - .5)/r
andSin[a] = (y - .5)/r
-
random over 13 yearsCheck the algorithm in this link - davis.wpi.edu/~matt/courses/morph/2d.htm Can we have an algorithm like this for bulge effect?
-
random over 13 yearsThanks belisarius. I now need to implement it by adding a mesh to a Sprite in Android and applying the deformation to it. We have a library called andEngine which we can utilize. I have created another thread to proceed further: stackoverflow.com/questions/5078240/…
-
Dr. belisarius over 13 years@user193545 Can't help you wih that one. Good luck!
-
BlueRaja - Danny Pflughoeft about 13 yearsSee also my followup to this answer here
-
arunkumar.p almost 13 yearsCan you explain as briefly with any example
-
Vivek Kumar Srivastava almost 13 yearsI am unable to get above effect by using your alogorithm.
-
Ajay Sharma over 12 years@belisarius Can you help me with detecting the Objects shape witin an image ?
-
Dr. belisarius over 12 years@Ajay May be. Post a question and ping me again :)
-
CCJ over 11 years@belisarius I'm interested in garnering a deeper understanding of the math involved in the image warp you describe above; I've opened a thread over at math.stackexchange.com to that end: math.stackexchange.com/questions/266250/… I'd really appreciate your input! Thanks very much!
-
AAnkit over 11 yearshow to use it in Android with bitmap?