# 双线性插值

双线性插值是一种估算矩形网格单元内某点函数值的方法：利用该单元四个角上的已知值，先沿一个方向做线性插值，再沿另一个方向做一次。这个名字说的正是这个意思：在二维分段线性插值中，“双线性”就是指沿两个不同方向分别线性。<sup>[1](https://courses.physics.illinois.edu/ece417/fa2019/slides/lec12_interpolation.html)</sup> 它是图像处理、地理信息系统以及计算机图形学纹理过滤中的标准重采样方法之一。<sup>[2](https://learn.arcgis.com/en/projects/explore-imagery-spatial-resolution/)</sup><sup> • </sup><sup>[3](https://www.ipol.im/pub/art/2011/g_lmii/revisions/2011-09-27/g_lmii.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 输入 | 一个网格单元四角上的四个已知值，加上查询点在该单元内的坐标<sup>[4](https://docs.amd.com/r/2025.2-English/Vitis-Tutorials-AI-Engine-Development/Computing-Interpolated-Values?contentId=__SFhHwiEKA9ofrOYaT28A)</sup> |
| 步骤 | 两次连续的线性插值：先沿一个维度做一次，再沿另一个维度做一次<sup>[4](https://docs.amd.com/r/2025.2-English/Vitis-Tutorials-AI-Engine-Development/Computing-Interpolated-Values?contentId=__SFhHwiEKA9ofrOYaT28A)</sup> |
| 核尺寸 | 源像素的 2×2 邻域；相比之下，三次卷积为 4×4，Lanczos 为 6×6<sup>[5](https://gdal.org/en/stable/development/rfc/rfc51_rasterio_resampling_progress.html)</sup> |
| 输出特性 | 比最近邻重采样更平滑，但双线性和双三次在放大时都会产生模糊图像<sup>[2](https://learn.arcgis.com/en/projects/explore-imagery-spatial-resolution/)</sup><sup> • </sup><sup>[6](https://doi.org/10.1109/ICIG.2009.122)</sup> |
| 精度等级 | 分段线性插值是二阶精度的；其误差界涉及底层函数的二阶导数<sup>[7](https://ocw.mit.edu/courses/2-086-numerical-computation-for-mechanical-engineers-fall-2014/fbffccb918511874abd8fd8b3f256688_MIT2_086F14_Interpolation.pdf)</sup> |
| 实用地位 | 可以说是能产生连续函数的最简单的可分离方法；效率极高，且在许多平台上都有硬件支持<sup>[3](https://www.ipol.im/pub/art/2011/g_lmii/revisions/2011-09-27/g_lmii.html)</sup> |

## 工作原理

**两趟线性插值。** 已知某单元四角 \( (x_1, y_1) \)、\( (x_2, y_1) \)、\( (x_1, y_2) \)、\( (x_2, y_2) \) 处的值，以及单元内一个查询点 \( (x_q, y_q) \)，该方法先在两行上分别沿 \( x \) 方向插值：

\[ f(x_q, y_1) = \frac{(x_2 - x_q)}{(x_2 - x_1)} f(x_1, y_1) + \frac{(x_q - x_1)}{(x_2 - x_1)} f(x_2, y_1) \]

在 \( y_2 \) 处同理。然后再沿 \( y \) 方向在这两个中间值之间插值：

\[ f(x_q, y_q) = \frac{(y_2 - y_q)}{(y_2 - y_1)} f(x_q, y_1) + \frac{(y_q - y_1)}{(y_2 - y_1)} f(x_q, y_2). \]

把两步合并，得到闭式表达<sup>[4](https://docs.amd.com/r/2025.2-English/Vitis-Tutorials-AI-Engine-Development/Computing-Interpolated-Values?contentId=__SFhHwiEKA9ofrOYaT28A)</sup>

\[ f(x_q, y_q) = \frac{1}{(x_2 - x_1)(y_2 - y_1)} \begin{bmatrix} x_2 - x_q & x_q - x_1 \end{bmatrix} \begin{bmatrix} f(x_1, y_1) & f(x_1, y_2) \\ f(x_2, y_1) & f(x_2, y_2) \end{bmatrix} \begin{bmatrix} y_2 - y_q \\ y_q - y_1 \end{bmatrix}. \]

两趟的先后顺序无关紧要；先沿 \( y \) 再沿 \( x \) 插值，结果相同。

**实践中的网格查找。** 当网格是规则采样的数组（例如图像）时，整个过程简化为三步：把查询点变换到网格的坐标系中，将坐标拆成整数部分和小数部分，再按整数部分和整数部分加一取出四个控制点，用小数部分作为权重对它们加权。对于一个环绕式的 256×256 纹理和坐标 \( (3.1, -7.25) \)，该点先在单位空间中环绕到 \( (0.1, 0.75) \)，再缩放到网格空间中的 \( (25.6, 192) \)；整数部分 \( (25, 192) \) 用于选取控制点，小数部分 \( (0.6, 0) \) 则提供插值权重。<sup>[8](https://courses.grainger.illinois.edu/cs418/fa2025/text/lerp.html)</sup>

## 性质

双线性插值是连续的，但并不光滑：重建出的曲面在单元边界处连续，但其导数从一个单元到下一个单元会发生突变，这正是需要更高阶方法的原因。在可分离插值方法中，它是能产生连续函数的最简单的一种，而且效率极高，在许多平台上都有硬件支持，因此适合实时应用。<sup>[3](https://www.ipol.im/pub/art/2011/g_lmii/revisions/2011-09-27/g_lmii.html)</sup>

它的精度可由分段线性插值理论推出。对于以间距 \( h \) 采样的光滑函数做一维分段线性插值，局部误差满足

\[ e_i \leq \frac{h^2}{8} \max_{x \in S_i} |f''(x)|, \]

该方法具有二阶精度，以 \( h^2 \) 的速率收敛，而不是分段常数插值的 \( h \)。这个界依赖于二阶导数，因此要求该导数存在；插值同样依赖光滑性，对于含噪数据并不是好策略。<sup>[7](https://ocw.mit.edu/courses/2-086-numerical-computation-for-mechanical-engineers-fall-2014/fbffccb918511874abd8fd8b3f256688_MIT2_086F14_Interpolation.pdf)</sup> 在一般四边形而非矩形上，误差行为取决于该四边形的几何特征，这一关系在有限元文献中针对 \( Q_1 \) 单元有过研究。<sup>[9](https://epubs.siam.org/doi/abs/10.1137/070700486)</sup>

一个密切相关的方法是在采样点三角剖分上做线性插值，其中每个三角形用与其顶点数据相匹配的仿射函数来插值。<sup>[3](https://www.ipol.im/pub/art/2011/g_lmii/revisions/2011-09-27/g_lmii.html)</sup>

## 应用

**图像重采样与超分辨率。** 双线性插值是放大图像的标准方法之一，与最近邻、双三次、Lanczos 和样条方法并列。<sup>[10](https://www.sciencedirect.com/science/article/pii/S1877050924005994)</sup> 在使用均方误差和峰值信噪比进行的对比评估中，双三次方法的得分优于双线性和最近邻。<sup>[11](https://journal.ukmc.ac.id/index.php/jutsi/article/view/428)</sup> 代价在于计算成本：最近邻插值计算简单，但图像被大幅放大时会产生块状结果，而一阶（双线性）插值在变换后的图像中视觉观感更好。<sup>[12](https://www.cs.auckland.ac.nz/courses/compsci773s1c/lectures/ImageProcessing-html/topic2.htm)</sup> 双三次和双线性插值都会使图像模糊，尤其是在放大时。<sup>[6](https://doi.org/10.1109/ICIG.2009.122)</sup>

**地理栅格。** 在 GIS 软件中，双线性重采样通过平均原始栅格中四个相邻单元来计算每个输出单元的值，输出比最近邻更平滑，后者直接复制最近单元的精确值；三次卷积则平均 16 个相邻单元。<sup>[2](https://learn.arcgis.com/en/projects/explore-imagery-spatial-resolution/)</sup> GDAL 库在 `gdal_translate` 等工具中将双线性作为一种卷积核重采样选项提供，并且在即时重投影垂直位移大地水准面网格时默认使用双线性重采样。<sup>[13](https://gdal.org/en/stable/programs/gdal_translate.html)</sup><sup> • </sup><sup>[14](https://gdal.org/en/stable/api/gdal_alg.html)</sup> 分类栅格或专题栅格是例外：它们只应使用最近邻或众数方法重采样，因为其原始单元值必须保留。<sup>[2](https://learn.arcgis.com/en/projects/explore-imagery-spatial-resolution/)</sup>

**图形学中的纹理过滤。** 在 OpenGL 中，把放大过滤器设为 `GL_LINEAR` 即对二维纹理执行双线性过滤：采样器取纹理坐标周围的 2×2 个纹素并将它们混合，每个纹素的贡献按其到采样点的距离加权。<sup>[15](https://wikis.khronos.org/opengl/Sampler_Object)</sup><sup> • </sup><sup>[16](https://learnopengl.com/book/learnopengl_book_bw.pdf)</sup> 把这一思路推广到三维，就得到三线性插值，有八个控制点和三个参数；在 mipmap 过滤中，`GL_LINEAR_MIPMAP_LINEAR` 利用最近的两个 mipmap 层级以及每个层级上的网格，执行一次三线性插值。<sup>[8](https://courses.grainger.illinois.edu/cs418/fa2025/text/lerp.html)</sup>

**软件实现。** 双线性插值是图像库和栅格库中的内置选项。OpenCV 的 `warpAffine`、`warpPerspective` 和 `remap` 过去使用基于查表的近似；OpenCV 4 到 5 的过渡用修订后的双线性和双三次插值取代了它们，不再依赖那些近似，因此结果更精确、通常也更快，数值输出与 OpenCV 4.x 略有不同，且更接近数学上的精确结果。<sup>[17](https://github.com/opencv/opencv/wiki/OpenCV-4-to-5-migration)</sup>

## 与其他方法的关系

双线性属于一类可分离线性插值方法，这一类还包括最近邻、双三次、样条和 sinc 插值。<sup>[3](https://www.ipol.im/pub/art/2011/g_lmii/revisions/2011-09-27/g_lmii.html)</sup> sinc 插值的核为 \( \mathrm{sinc}(t) = \sin(\pi t)/(\pi t) \)，对带限函数是精确的，因此在光滑数据上非常准确，但它衰减缓慢，速率为 \( 1/x \)，并且在有混叠的图像中会在边缘附近产生明显的波纹伪影（吉布斯现象）。<sup>[3](https://www.ipol.im/pub/art/2011/g_lmii/revisions/2011-09-27/g_lmii.html)</sup> 双线性避免了这种振铃，代价是精度较低并带有一定程度的平滑。

同样的两趟思路可以沿多个轴推广。三线性插值用八个控制点处理三维。<sup>[8](https://courses.grainger.illinois.edu/cs418/fa2025/text/lerp.html)</sup> 张量积曲面片把贝塞尔曲线的重复线性插值技术应用于双线性插值，而 3D 图形程序中广泛使用的 NURBS 就是这类曲面片的一种变体。<sup>[8](https://courses.grainger.illinois.edu/cs418/fa2025/text/lerp.html)</sup> 在有限元方法中，四边形网格上的双线性 \( Q_1 \) 单元是标准的最低阶张量积单元，其插值误差估计与单元的形状有关。<sup>[9](https://epubs.siam.org/doi/abs/10.1137/070700486)</sup>

## References

1. [ECE 417 Lecture 12: Piece-wise linear (bilinear) interpolation, University of Illinois](https://courses.physics.illinois.edu/ece417/fa2019/slides/lec12_interpolation.html)
2. [Explore imagery – Spatial resolution, ArcGIS documentation](https://learn.arcgis.com/en/projects/explore-imagery-spatial-resolution/)
3. [Linear Methods for Image Interpolation, IPOL Journal](https://www.ipol.im/pub/art/2011/g_lmii/revisions/2011-09-27/g_lmii.html)
4. [Computing Interpolated Values, AMD Vitis AI Engine Development documentation (2025.2)](https://docs.amd.com/r/2025.2-English/Vitis-Tutorials-AI-Engine-Development/Computing-Interpolated-Values?contentId=__SFhHwiEKA9ofrOYaT28A)
5. [RFC 51: RasterIO() improvements, GDAL documentation](https://gdal.org/en/stable/development/rfc/rfc51_rasterio_resampling_progress.html)
6. [Methods of Increasing Spatial Resolution of Digital Images with Minimum Detail Loss, ICIG 2009, IEEE](https://doi.org/10.1109/ICIG.2009.122)
7. [Interpolation, MIT 2.086 Numerical Computation for Mechanical Engineers (Fall 2014)](https://ocw.mit.edu/courses/2-086-numerical-computation-for-mechanical-engineers-fall-2014/fbffccb918511874abd8fd8b3f256688_MIT2_086F14_Interpolation.pdf)
8. [Linear interpolation, CS 418 course text, University of Illinois (Luther Tychonievich)](https://courses.grainger.illinois.edu/cs418/fa2025/text/lerp.html)
9. [On the Interpolation Error Estimates for Q1 Quadrilateral Finite Elements, SIAM Journal on Numerical Analysis](https://epubs.siam.org/doi/abs/10.1137/070700486)
10. [A Comparative Study Of Super-Resolution Interpolation Techniques, ScienceDirect](https://www.sciencedirect.com/science/article/pii/S1877050924005994)
11. [Analisis Hasil Resolusi Citra Dengan Metode Interpolasi Nearest Neighbor, Bilinear, dan Bicubic, JuSiTik](https://journal.ukmc.ac.id/index.php/jutsi/article/view/428)
12. [Geometric Operations, COMPSCI 773 lecture notes, University of Auckland](https://www.cs.auckland.ac.nz/courses/compsci773s1c/lectures/ImageProcessing-html/topic2.htm)
13. [gdal_translate, GDAL documentation](https://gdal.org/en/stable/programs/gdal_translate.html)
14. [gdal_alg.h: GDAL Algorithms C API, GDAL documentation](https://gdal.org/en/stable/api/gdal_alg.html)
15. [Sampler Object, OpenGL Wiki, Khronos Group](https://wikis.khronos.org/opengl/Sampler_Object)
16. [LearnOpenGL book (texture filtering section)](https://learnopengl.com/book/learnopengl_book_bw.pdf)
17. [OpenCV 4 to 5 migration, opencv/opencv Wiki, GitHub](https://github.com/opencv/opencv/wiki/OpenCV-4-to-5-migration)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026; Oct 25, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 数学分析与数学模型 › Numerical analysis and computation

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/bilinear-interpolation

English original: https://www.edgepedia.org/bilinear-interpolation
