且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

图像变形 - Bulge Effect 算法

更新时间:2023-10-30 18:13:34

看看我是否明白你想要什么.假设您的图像坐标从 0 到 1.

See if I understood what you want. Suppose your image coordinates go from 0 to 1.

如果你这样做:

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 may adjust the parameters to get bigger or smaller bulges.

编辑

让我们看看我是否理解您对翘曲的评论.以下图片使用

Let's see if I understood your comment about warping. The following images are generated using

rn = r^k {k: 1 ... 2}: