以编程方式向图像添加凸面效果

发布于 2024-12-19 13:52:58 字数 94 浏览 1 评论 0原文

我正在寻找一些算法来为图像添加凸面镜效果和凹面镜效果。我还想知道如何有效地实现这一点:将算法应用于图像数据或通过包含效果的透明图像覆盖它。但我认为第二种选择不适用于这种情况。

I am looking for some algorithms to add a convex mirror effect and concave mirror effect to an image. I want to know also how to make this efficiently: applying the algorithm to image data or overlay it by a transparent image that contains the effect. But I don't think the second choice is applicable in this case.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧时光的容颜 2024-12-26 13:52:58

如果您手动执行此操作而不是使用硬件基元,那么布雷森汉姆插值算法(通常用于画线)就是最佳选择:错误传播比其他更复杂的方法高效得多。

布雷森汉姆所做的只是插值。不要错过在其他地方使用其高效设计的机会(线条绘制的坡度计算只是插值的众多应用之一:您可以插值另一个维度:2D、3D、透明度、反射、颜色等)。

25 年前,我记得曾用它来调整位图大小,甚至在实时 3D 引擎中进行纹理映射!当时图形加速视频板花费了一大笔钱......

If you are doing it manually instead of using hardware primitives, then the bresenham interpolation algorithm (usually used for line drawing) is the way to go: error propagation is far more efficient than other, more complex, methods.

What Bresenham does is just interpolation. Don't miss the opportunity to use its efficient design elsewhere (slope calculation for line-drwaing is just one of the many applications of interpolation: you can interpolate another dimension: 2D, 3D, transparency, reflection, colors, etc.).

25 years ago, I remember having used it to resize bitmaps and even do texture mapping in a real-time 3D engine! That was at a time graphic-accelerated video boards costed a fortune...

二智少女猫性小仙女 2024-12-26 13:52:58

CImg 库有一个鱼眼示例,位于 Examples\CImg_demo.cpp 中。核心算法看起来非常简单(而且速度很快,就像这个库一样)。我认为这是真实光学效果的近似值,但可以进行修改以处理凸面镜面。我不知道它是否可以扩展到处理“负”曲率。

CImg library has a fisheye sample, in examples\CImg_demo.cpp. The core algorithm seems very simple (and fast, as generally this library). I think it's an approximation of the real optical effect, but could be modified to handle the convex mirroring. I don't know if it could be extended to handle 'negative' curvature.

爱*していゐ 2024-12-26 13:52:58

您可以使用预先计算的 sin() 表并插入值以匹配位图的大小。通过使用偏移量或更大的表可以实现相反的效果。

还记得 80 年代 DOS 演示的(伟大时代)...

You can use a pre-calculated sin() table and interpolate values to match the size of your bitmap. The inverse effect is achieved by either using an offset or a larger table.

Remembers me the (great times of the) DOS demos in the 80s...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文