# 仿射变换

仿射变换是一种几何映射，它将线性变换（如旋转、缩放或错切）与平移组合在一起，从而将点 \( \mathbf{x} \) 映射为 \( A\mathbf{x} + \mathbf{b} \)，其中 \( A \) 为矩阵，\( \mathbf{b} \) 为向量。它保持直线的平直性、直线的平行性、共线点之间的距离比以及平行线段的长度比，但不一定保持长度、角度或任意距离之比。<sup>[1](https://github.com/opencv/opencv/blob/5.x/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.markdown)</sup><sup> • </sup><sup>[2](https://www.cfm.brown.edu/people/dobrush/cs52/Mathematica/Part1/affine.html)</sup><sup> • </sup><sup>[18](https://www.cambridge.org/core/books/abs/geometry-and-topology/affine-geometry/0674FFD5F276B030B8915D9B97DE82E3)</sup>

| 关键事实 | 详情 |
|---|---|
| 形式 | 先做矩阵乘法（线性变换），再做向量加法（平移）；在二维图像处理中通常写成一个 \( 2 \times 3 \) 矩阵<sup>[1](https://github.com/opencv/opencv/blob/5.x/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.markdown)</sup> |
| 保持的性质 | 直线的平行性、点的共线性，以及沿平行线的距离之比，但不保持任意距离<sup>[2](https://www.cfm.brown.edu/people/dobrush/cs52/Mathematica/Part1/affine.html)</sup> |
| 可表达的运动 | 旋转、平移和缩放等<sup>[1](https://github.com/opencv/opencv/blob/5.x/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.markdown)</sup> |
| 可逆性 | 仿射变换可逆当且仅当其线性部分 \( A \) 可逆；其逆变换本身也是仿射变换<sup>[3](https://www.datacamp.com/tutorial/affine-transformation)</sup><sup> • </sup><sup>[4](https://math.nyu.edu/~dy444/MA-GY7043Spring2025/lectures/MA-GY7043Spring2025Lecture20250424.pdf)</sup> |
| 复合 | 仿射变换的复合仍是仿射变换<sup>[2](https://www.cfm.brown.edu/people/dobrush/cs52/Mathematica/Part1/affine.html)</sup> |
| 齐次形式 | 增加一个额外坐标，即可将二维仿射变换写成单个 \( 3 \times 3 \) 矩阵乘法<sup>[3](https://www.datacamp.com/tutorial/affine-transformation)</sup> |
| 术语起源 | 莱昂哈德·欧拉（Leonhard Euler）于1748年引入“仿射”一词，源自拉丁语 *affinis*，意为“与……相连”<sup>[2](https://www.cfm.brown.edu/people/dobrush/cs52/Mathematica/Part1/affine.html)</sup> |

## 定义与代数形式

仿射变换是先做线性变换、再做平移的变换。用坐标表示，点 \( \mathbf{x} \) 映射为

\[ \mathbf{y} = A\mathbf{x} + \mathbf{b}, \]

其中 \( A \) 为可逆方阵（在退化用法中也可为任意方阵），\( \mathbf{b} \) 为固定向量。次序很重要：先施加线性映射，再施加平移。<sup>[5](https://www.math.ucla.edu/~baker/149.1.02w/handouts/h_affine_I/node3.html)</sup> 等价地说，一个变换是仿射的，当且仅当它可以写成平移与线性变换的复合。<sup>[6](https://mathweb.ucsd.edu/~sbuss/CourseWeb/Math155A_2019Winter/SecondEdDraft.pdf)</sup>

它与线性变换的区别就在于平移项。

形式化地说，仿射变换是从一个仿射空间到另一个仿射空间的映射，它保持仿射组合：对点 \( P \)、\( Q \) 和标量 \( \alpha \)、\( \beta \)，有 \( F(\alpha P + \beta Q) = \alpha F(P) + \beta F(Q) \)。点与点之间的向量按线性方式变换，因此 \( F(P + \alpha v) = F(P) + \alpha F(v) \)，且 \( F(u + v) = F(u) + F(v) \)。<sup>[2](https://www.cfm.brown.edu/people/dobrush/cs52/Mathematica/Part1/affine.html)</sup>

## 矩阵表示与齐次坐标

在二维情形下，通常的表示是一个 \( 2 \times 3 \) 矩阵，容纳 \( A \) 与 \( \mathbf{b} \) 的六个系数。<sup>[1](https://github.com/opencv/opencv/blob/5.x/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.markdown)</sup> 由于平移是向量加法而非乘法，\( 2 \times 3 \) 形式无法作为单个矩阵乘积作用于普通坐标。

同样的六数编码也出现在地理空间软件中。在 GDAL 中，地理变换（geotransform）是一个从图像坐标空间（以像素索引和行索引给出）到地理参考坐标空间的仿射变换，由六个系数定义：

\[ X_{\mathrm{geo}} = GT(0) + X_{\mathrm{pixel}} \cdot GT(1) + Y_{\mathrm{line}} \cdot GT(2), \]
\[ Y_{\mathrm{geo}} = GT(3) + X_{\mathrm{pixel}} \cdot GT(4) + Y_{\mathrm{line}} \cdot GT(5). \]

这里 \( GT(0) \) 与 \( GT(3) \) 定位左上像素的左上角，\( GT(1) \) 与 \( GT(5) \) 为像素宽度与高度，\( GT(2) \) 与 \( GT(4) \) 为旋转项，对于北向上的图像通常为零。<sup>[8](https://gdal.org/en/stable/tutorials/geotransforms_tut.html)</sup>

## 性质

**对复合与求逆的封闭性。** 若仿射变换有逆，则该逆也是仿射变换；仿射变换的复合仍是仿射变换。<sup>[2](https://www.cfm.brown.edu/people/dobrush/cs52/Mathematica/Part1/affine.html)</sup> 整个映射的可逆性归结为线性部分：仿射映射可逆当且仅当其线性部分 \( A \) 可逆。<sup>[3](https://www.datacamp.com/tutorial/affine-transformation)</sup><sup> • </sup><sup>[4](https://math.nyu.edu/~dy444/MA-GY7043Spring2025/lectures/MA-GY7043Spring2025Lecture20250424.pdf)</sup>

**几何不变量。** 仿射变换保持直线的平行性、点的共线性、同一直线上点与点之间的距离之比，以及平行线段的长度之比，因此在任何仿射映射下——即便是对图形做错切或拉伸的映射——平行线仍保持平行，中点仍是中点。<sup>[2](https://www.cfm.brown.edu/people/dobrush/cs52/Mathematica/Part1/affine.html)</sup> 它们一般并不保持长度或角度；保持长度与角度的变换——平移、旋转和反射——构成限制更强的欧几里得（刚性）类，而在计算机视觉所用的变换群层级中，相似变换介于刚性与仿射之间。<sup>[9](https://perspectiveresearchcentre.com/projective-transformation/)</sup><sup> • </sup><sup>[10](https://www.cs.cmu.edu/~16385/lectures/lecture9.pdf)</sup>

## 应用

**图像处理。** 在计算机视觉库中，仿射变换用来表达两幅图像在旋转、平移和缩放下的关系。OpenCV 用函数 `cv::warpAffine` 施加仿射变换，并用 `cv::getRotationMatrix2D` 构造 \( 2 \times 3 \) 旋转矩阵。<sup>[1](https://github.com/opencv/opencv/blob/5.x/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.markdown)</sup> 苹果的 Accelerate 框架同样提供例程，可对平面图像施加单精度仿射变换。<sup>[11](https://developer.apple.com/documentation/accelerate/applying-affine-transformations-to-images?changes=_2_8__8&language=objc)</sup>

**图像配准。** 对同一场景的两幅图像进行配准，即把它们对齐到共同坐标系中，通常通过估计两个坐标系之间仿射变换的系数来完成；NASA 的配准工作正是以这种系数形式描述空间变换的映射函数。<sup>[12](https://ntrs.nasa.gov/api/citations/20040085737/downloads/20040085737.pdf?attachment=true)</sup>

**栅格数据的地理配准。** GIS 库将栅格在地球上的位置存储为仿射地理变换，即上述六系数映射，并提供求逆例程，把方程从“像素到地理”形式转换为“地理到像素”形式。<sup>[8](https://gdal.org/en/stable/tutorials/geotransforms_tut.html)</sup><sup> • </sup><sup>[13](https://gdal.org/en/stable/api/raster_c_api.html)</sup>

**密码学。** 该术语也出现在分组密码设计中：NIST 的术语表在 FIPS 197（高级加密标准）的语境下定义了仿射变换，该标准在密码的各层内部使用有限域上的仿射映射。<sup>[14](https://csrc.nist.gov/glossary/term/affine_transformation)</sup>

## 在几何学中的地位

“仿射”一词随欧拉1748年的《无穷分析引论》（*Introductio in analysin infinitorum*）进入数学。<sup>[2](https://www.cfm.brown.edu/people/dobrush/cs52/Mathematica/Part1/affine.html)</sup><sup> • </sup><sup>[15](https://scholarlycommons.pacific.edu/euler-works/101/)</sup> 在菲利克斯·克莱因（Felix Klein）1872年埃尔朗根纲领所确立的几何分类中，每种几何都是对某一变换群下不变性质的研究：使用运动得到欧几里得几何，把运动替换为仿射变换或射影变换，就得到仿射几何或射影几何。<sup>[16](https://encyclopediaofmath.org/wiki/Erlangen_program)</sup> 在微分几何内部，关于曲线与曲面在仿射变换群下性质的研究始于特朗松（Transon）1841年发表的一个结果；对等仿射（幺模）群的系统研究始于1916年，第一部仿射微分几何专著于1923年问世。<sup>[17](https://www.sciencedirect.com/topics/mathematics/affine-geometry)</sup>

## References

1. [Affine Transformations, OpenCV tutorial (warp_affine)](https://github.com/opencv/opencv/blob/5.x/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.markdown)
2. [Linear Algebra, Part 1: Affine transformations, Brown University (Mathematica course notes)](https://www.cfm.brown.edu/people/dobrush/cs52/Mathematica/Part1/affine.html)
3. [Affine Transformation Explained: Properties and Applications, DataCamp](https://www.datacamp.com/tutorial/affine-transformation)
4. [MA-GY 7043: Linear Algebra II, Lecture notes, New York University](https://math.nyu.edu/~dy444/MA-GY7043Spring2025/lectures/MA-GY7043Spring2025Lecture20250424.pdf)
5. [h_affine_I handout, UCLA Math](https://www.math.ucla.edu/~baker/149.1.02w/handouts/h_affine_I/node3.html)
6. [Math 155A course text, UC San Diego (S. Buss)](https://mathweb.ucsd.edu/~sbuss/CourseWeb/Math155A_2019Winter/SecondEdDraft.pdf)
7. [Linear Transformations, Boston University CS 132 course text](https://www.cs.bu.edu/fac/snyder/cs132-book/L07LinearTransformations.html)
8. [Geotransform Tutorial, GDAL documentation](https://gdal.org/en/stable/tutorials/geotransforms_tut.html)
9. [Projective Transformation, Perspective Research Centre](https://perspectiveresearchcentre.com/projective-transformation/)
10. [Lecture 9: Transformations, CMU 16-385 Computer Vision](https://www.cs.cmu.edu/~16385/lectures/lecture9.pdf)
11. [Applying affine transformations to images, Apple Developer Documentation](https://developer.apple.com/documentation/accelerate/applying-affine-transformations-to-images?changes=_2_8__8&language=objc)
12. [Multi-image registration for an enhanced vision system, NASA NTRS](https://ntrs.nasa.gov/api/citations/20040085737/downloads/20040085737.pdf?attachment=true)
13. [gdal.h: Raster C API, GDAL documentation](https://gdal.org/en/stable/api/raster_c_api.html)
14. [Affine Transformation, NIST CSRC Glossary](https://csrc.nist.gov/glossary/term/affine_transformation)
15. [Introductio in analysin infinitorum, volume 1, Leonhard Euler (1748), Pacific University Scholarly Commons](https://scholarlycommons.pacific.edu/euler-works/101/)
16. [Erlangen program, Encyclopedia of Mathematics](https://encyclopediaofmath.org/wiki/Erlangen_program)
17. [Affine Geometry, ScienceDirect Topics](https://www.sciencedirect.com/topics/mathematics/affine-geometry)
18. [Affine geometry (Chapter 4) - Geometry and Topology](https://www.cambridge.org/core/books/abs/geometry-and-topology/affine-geometry/0674FFD5F276B030B8915D9B97DE82E3)

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

Topic: 物质世界与数学 › 数学与统计学 › 几何学与拓扑学 › Projective and affine geometry

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/affine-transformation

English original: https://www.edgepedia.org/affine-transformation
