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

问题描述

我浏览了互联网,就双三次插值而言,我找不到一个简单的方程式.维基百科上关于该主题的页面不是很有帮助,因此,有什么简单的方法来学习双三次插值如何工作以及如何实现?我正在使用它生成Perlin Noise,但是使用双线性插值法可以满足我的需求(我已经尝试过).

I looked through the internet, and in terms of Bicubic Interpolation, I can't find a simple equation for it. Wikipedia's page on the subject wasn't very helpful, so is there any easy method to learning how Bicubic Interpolation works and how to implement it? I'm using it to generate Perlin Noise, but using bilinear interpolation is way to choppy for my needs (I already tried it).

如果任何人都可以通过一个好的网站或只是一个答案将我指向正确的方向,我将不胜感激. (顺便说一下,我正在使用C#)

If anyone can point me in the right direction by either a good website or just an answer, I would greatly appreciate it. (I'm using C# by the way)

推荐答案

使用(感谢AhmetKakıcı发现了这个问题),我弄清楚了如何添加Bicubic Interpolation.对于那些也在寻找答案的人,这是我所使用的:

Using this (Thanks to Ahmet Kakıcı who found this), I figured out how to add Bicubic Interpolation. For those also looking for the answer, here is what I used:

private float CubicPolate( float v0, float v1, float v2, float v3, float fracy ) {
    float A = (v3-v2)-(v0-v1);
    float B = (v0-v1)-A;
    float C = v2-v0;
    float D = v1;

    return A*Mathf.Pow(fracy,3)+B*Mathf.Pow(fracy,2)+C*fracy+D;
}

为了获得2D插值,我首先获得x,然后对y进行插值.例如

In order to get 2D Interpolation, I first got the x, then interpolated the y. Eg.

float x1 = CubicPolate( ndata[0,0], ndata[1,0], ndata[2,0], ndata[3,0], fracx );
float x2 = CubicPolate( ndata[0,1], ndata[1,1], ndata[2,1], ndata[3,1], fracx );
float x3 = CubicPolate( ndata[0,2], ndata[1,2], ndata[2,2], ndata[3,2], fracx );
float x4 = CubicPolate( ndata[0,3], ndata[1,3], ndata[2,3], ndata[3,3], fracx );

float y1 = CubicPolate( x1, x2, x3, x4, fracy );

其中ndata定义为:

Where ndata is defined as:

float[,] ndata = new float[4,4];
for( int X = 0; X < 4; X++ )
    for( int Y = 0; Y < 4; Y++ )
        //Smoothing done by averaging the general area around the coords.
        ndata[X,Y] = SmoothedNoise( intx+(X-1), inty+(Y-1) );

(intx和inty是所请求坐标的下限值.fracx和fracy是输入坐标的小数部分,分别为x-intxy-inty)

(intx and inty are the floored values of the requested coordinates. fracx and fracy are the fractional parts of the inputted coordinates, to be x-intx, and y-inty, respectively)

这篇关于双三次插值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 14:11