图像扭曲过滤器 - 算法和光栅化

发布于 2024-11-07 18:00:48 字数 279 浏览 4 评论 0原文

我想实现一个过滤器,允许通过移动标记边缘和切线方向的多个控制点来对图像进行重新采样。目标是当您使用“自由变换”并选择变形模式“自定义”时,能够自由地变换图像,如 Photoshop 中所示。该图像被安装到某种可以操作的样条线补丁(如果这是一个有效的名称)中。

我了解简单样条线(路径)的工作原理,但如何将它们连接起来形成补丁? 如何对这样的补丁进行采样来渲染变形图像?对于目标中的每个像素,我需要知道源图像中对应的像素。我什至不知道从哪里开始搜索...

任何有用的信息(关键字、链接、论文、参考实现)都非常感谢!

I'd like to implement a Filter that allows resampling of an image by moving a number of control points that mark edges and tangent directions. The goal is to be able to freely transform an image as seen in Photoshop when you use "Free Transform" and chose Warpmode "Custom". The image is fitted into a some kind of Spline-Patch (if that is a valid name) that can be manipulated.

I understand how simple splines (paths) work but how do you connect them to form a patch?
And how can you sample such a patch to render the morphed image? For each pixel in the target I'd need to know what pixel in the source image corresponds. I don't even know where to start searching...

Any helpful info (keywords, links, papers, reference implementations) are greatly appreciated!

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

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

发布评论

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

评论(1

向日葵 2024-11-14 18:00:48

本文档将帮助您深入了解扭曲:http://www.gson.org/ thesis/warping-thesis.pdf

然而,这将包括滤除高频,这将使实现变得更加复杂,但会给出更好的结果。

完成您想要做的事情的一个简单方法是循环遍历最终图像中的每个像素,将坐标插入样条线并检索原始图像中的像素。该像素的坐标可能为 0.4/1.2,因此您可以在 0/1、1/1、0/2 和 1/2 之间进行双线性插值。

至于样条线:对于一维情况,网上有很多资源和解决方案。至于 2D,找到有用的资源会有点棘手。
一维情况的简单示例: http://www -users.cselabs.umn.edu/classes/Spring-2009/csci2031/quad_spline.pdf

这是一个很好的指南2D 情况: http://en.wikipedia.org/wiki/Bicubic_interpolation

基于此,您可以为 2D 情况导出自己的样条曲线方案。定义一个二元(包含 x 和 y)多项式并设置约束来求解多项式的系数。
请记住,样条面片的边界必须保持一致(无论是值还是导数),以避免出现难看的跳跃。

祝你好运!

This document will get you a good insight into warping: http://www.gson.org/thesis/warping-thesis.pdf

However, this will include filtering out high frequencies, which will make the implementation a lot more complicated but will give a better result.

An easy way to accomplish what you want to do would be to loop through every pixel in your final image, plug the coordinates into your splines and retrieve the pixel in your original image. This pixel might have coordinates 0.4/1.2 so you could bilinearly interpolate between 0/1, 1/1, 0/2 and 1/2.

As for splines: there are many resources and solutions online for the 1D case. As for 2D it gets a bit trickier to find helpful resources.
A simple example for the 1D case: http://www-users.cselabs.umn.edu/classes/Spring-2009/csci2031/quad_spline.pdf

Here's a great guide for the 2D case: http://en.wikipedia.org/wiki/Bicubic_interpolation

Based upon this you could derive an own scheme for splines for the 2D case. Define a bivariate (with x and y) polynomial and set your constraints to solve for the coefficients of the polynomial.
Just keep in mind that the borders of the spline patches have to be consistent (both in value and derivative) to avoid ugly jumps.

Good luck!

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