25

双线性插值(Bilinear Interpolation)

 3 years ago
source link: http://www.banbeichadexiaojiubei.com/index.php/2020/12/13/双线性插值bilinear-interpolation/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

线性插值

已知中P1点和P2点,坐标分别为(x1, y1)、(x2, y2),要计算 [x1, x2] 区间内某一位置 x 在直线上的y值:

jyuI7j7.png!mobile

根据初中的几何知识:

$$

\begin{equation}

\frac{y – y_0}{x – x_0} = \frac{y_1 – y_0}{x_1 – x_0}

\end{equation}

$$

$$

\begin{equation}

y = \frac{x_1 – x}{x_1 – x_0}y_0 +\frac{x – x_0}{x_1 – x_0}y_1

\end{equation}

$$

$$

\begin{equation}

x = \frac{y_1 – y}{y_1 – y_0}x_0 +\frac{y – y_0}{y_1 – y_0}x_1

\end{equation}

$$

二次线性插值

二次线性插值是在两个方向分别进行一次线性插值。如下图所示, 已知Q11 = (x1, y1)、Q12 = (x1, y2), Q21 = (x2, y1) 以及 Q22 = (x2, y2) 四个点的值,先在x方向求2个一次线性插值,得到R1(x3, y3)、R2(x4, y4)两个临时点,再在y方向计算一次线性插值得出P(x, y)。

I7Bj63Z.jpg!mobile

先在x轴方向的两次线性插值:

$$

R_1 = f(x, y_1) \approx \frac{x_2-x}{x_2-x_1}f(Q_{11}) + \frac{x_2-x}{x_2-x_1}f(Q_{21})

$$

$$

R_2 = f(x, y_1) \approx \frac{x_2-x}{x_2-x_1}f(Q_{12}) + \frac{x_2-x}{x_2-x_1}f(Q_{22})

$$

再在y轴方向进行线性插值:

$$

f(x, y) \approx \frac{y_2-y}{y_2-y_1} R_1 + \frac{y-y_1}{y_2-y_1} R2

$$

先从y轴、再从x轴进行线性插值的结果是一样的。

参考材料

https://zhuanlan.zhihu.com/p/110754637

https://bellobanana.cn/2019/11/23/dl/rookie/rookie-1/

除非注明,否则均为[半杯茶的小酒杯]原创文章,转载必须以链接形式标明本文链接

本文链接: http://www.banbeichadexiaojiubei.com/index.php/2020/12/13/%e5%8f%8c%e7%ba%bf%e6%80%a7%e6%8f%92%e5%80%bcbilinear-interpolation/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK