双线性插值与非对齐的输入点

双线性插值与非对齐的输入点

本文介绍了双线性插值与非对齐的输入点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非格栅对齐集与格对准的输出值相关联的输入值。鉴于我想找到输出一个新的输入值:

I have a non-grid-aligned set of input values associated with grid-aligned output values. Given a new input value I want to find the output:

                                 

                                 

(这些X,Y坐标,一种校准即时precise不方眼睛跟踪输入装置苛求在屏幕上的位置。)

(These are X,Y coordinates, calibrating an imprecise not-square eye-tracking input device to exact locations on screen.)

这看起来像双线性插值,但我的输入值不是网格对齐。给定的输入,我怎么能找出一个合理的产值?

This looks like Bilinear Interpolation, but my input values are not grid-aligned. Given an input, how can I figure out a reasonable output value?

答案:在这种情况下,我有两套输入输出点,什么是真正需要的是执行的找到U,V四中的坐标输入点,再进行正常双线性插值使用这些ü输出四(如下尼科的回答中所述), V坐标。

Answer: In this case where I have sets of input and output points, what is actually needed is to perform inverse bilinear interpolation to find the U,V coordinates of the input point within the quad, and then perform normal bilinear interpolation (as described in Nico's answer below) on the output quad using those U,V coordinates.

推荐答案

您可以双线性插值在任何凸四边形。一个笛卡尔网格仅仅是一个有点简单,因为插补参数的计算是微不足道的。在一般情况下,你插值,如下所示:

You can bilinearly interpolate in any convex tetragon. A cartesian grid is just a bit simpler because the calculation of interpolation parameters is trivial. In the general case you interpolate as follows:

parameters alpha, beta
interpolated value = (1 - alpha) * ((1 - beta) * p1 + beta * p2) + alpha * ((1 - beta) * p3 + beta * p4)

为了计算参数,你必须解决方程系统。摆在 P1 地方你的输入值通过 P4 并解决了字母测试版

In order to calculate the parameters, you have to solve a system of equations. Put your input values in the places of p1 through p4 and solve for alpha and beta.

然后把你的输出值在 P1 地方通过 P4 ,并使用计算的参数来计算最终的内插输出值。

Then put your output values in the places of p1 through p4 and use the calculated parameters to calculate the final interpolated output value.

有关规则网格,参数计算归结为:

For a regular grid, the parameter calculation comes down to:

alpha = x / cell width
beta  = y / cell height

自动解决的方程式。

which automatically solves the equations.

下面是一个采样插补的α= 0.3 的β= 0.6

Here is a sample interpolation for alpha=0.3 and beta=0.6

实际上,等式可以解析求解。但是,公式是相当难看。因此,迭代方法可能更好。有两种解决方案,方程系统。你需要选择其中两个参数是在溶液[0,1]。

Actually, the equations can be solved analytically. However, the formulae are quite ugly. Therefore, iterative methods are probably nicer. There are two solutions for the system of equations. You need to pick the solution where both parameters are in [0, 1].

解决方案一:

alpha = -(b e - a f + d g - c h + sqrt(-4 (c e - a g) (d f - b h) +
        (b e - a f + d g - c h)^2))/(2 c e - 2 a g)
beta  = (b e - a f - d g + c h + sqrt(-4 (c e - a g) (d f - b h) +
        (b e - a f + d g - c h)^2))/(2 c f - 2 b g)

其中

a = -p1.x + p3.x
b = -p1.x + p2.x
c = p1.x - p2.x - p3.x + p4.x
d = center.x - p1.x
e = -p1.y + p3.y
f = -p1.y + p2.y
g = p1.y - p2.y - p3.y + p4.y
h = center.y - p1.y

解决方法二:

Second solution:

alpha = (-b e + a f - d g + c h + sqrt(-4 (c e - a g) (d f - b h) +
        (b e - a f + d g - c h)^2))/(2 c e - 2 a g)
beta  = -((-b e + a f + d g - c h + sqrt(-4 (c e - a g) (d f - b h) +
        (b e - a f + d g - c h)^2))/( 2 c f - 2 b g))

这篇关于双线性插值与非对齐的输入点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 23:47