【问题标题】:Interpolation in uniform data grid with weighted corner points具有加权角点的均匀数据网格中的插值
【发布时间】:2013-12-10 06:35:36
【问题描述】:

这是我目前的情况:
我有一个二维均匀网格点,其中每个点都有一个关联的浮点值。
7---2
| . |
2---1

我可以使用双线性插值对这些点之间的值进行插值:

    public float GetValue(float x, float y, float topLeft, float topRight, 
                          float bottomLeft, float bottomRight)
    {
       return topLeft*(1-x)*(1-y) + topRight*x*(1-y) + 
              bottomLeft*(1-x)*y + bottomRight*x*y;
    }

现在我需要为每个点添加一个权重,以确定其对周围区域的影响程度。
例如:如果所有 4 个点的权重值相同,则这些权重会相互抵消,插值将返回与未加权版本完全相同的值。
现在假设所有点的权重为 1,除了左下角的权重值为 2 的点。在这种情况下,它的值对插值的影响是其他值的两倍,并且插值将转向有利于位于左下角的值。

基本上我正在尝试实现这样的方法:

    public float GetValue(float x, float y, float topLeftValue, topLeftWeight, 
                          float topRightValue, float topRightWeight,  
                          float bottomLeftValue, float bottomLeftWeight, 
                          float bottomRightValue, float bottomRightWeight)
    {
       return ?  
    }

有什么想法可以做到这一点吗?是否有考虑加权角值的方程/算法或双线性插值方法的修改?

感谢您的帮助!

【问题讨论】:

  • 因此,将权重乘以值并在双线性插值中使用这些值。

标签: c# math interpolation


【解决方案1】:

为了让事情变得更简单,假设 x = y = 0.5

如果所有4个点的权重值都相同,则返回值应该是

return topLeftValue/4 + topRightValue/4 + bottomLeftValue/4 + bottomRightValue/4;

现在,让所有点的权重为 1,除了左下角的权重值为 2 的点,返回值应该是

return topLeftValue/5 + topRightValue/5 + bottomLeftValue*2/5 + bottomRightValue/5;

bottomLeftValue的权重通过乘法调整

4*bottomLeftWeight / (topLeftWeight+topRightWeight+bottomLeftValue+bottomRightWeight)

现在,回到一般情况。 使用上述方法调整每个值的权重。 会变成

float overallWeight = topLeftWeight + topRightWeight + bottomLeftValue + bottomRightWeight; 

return topLeftValue*(1-x)*(1-y)*(4*topLeftWeight/overallWeight) + topRightValue*x*(1-y)*(4*topRightWeight/overallWeight) + bottomLeftValue*(1-x)*y*(4*bottomLeftWeight/overallWeight) + bottomRightValue*x*y*(4*bottomRightWeight/overallWeight)

【讨论】:

    猜你喜欢
    • 2023-03-28
    • 1970-01-01
    • 2014-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-01
    • 2018-11-08
    • 1970-01-01
    相关资源
    最近更新 更多