Image Warping - Bulge Effect Algorithm

后端 未结 2 921
别那么骄傲
别那么骄傲 2020-12-02 11:49

Can any point to image warping algorithms? Specifically for bulge effect?

相关标签:
2条回答
  • 2020-12-02 12:16

    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}: 
    

    0 讨论(0)
  • 2020-12-02 12:17

    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:

    enter image description here

    explosion:

    enter image description here

    implosion:

    enter image description here

    cheers!

    0 讨论(0)
提交回复
热议问题