📚 How We See – Mathematics of Perspective | 我们如何看见——透视的数学
How do we convert the three-dimensional world into a flat image that our brain can interpret? The answer lies in geometry and algebra – a fascinating branch of Further Mathematics that models the process of seeing through perspective, projection, and linear transformations. This article explores the mathematical principles behind how we see, from the rays of light entering the eye to the vanishing points in Renaissance art and the digital cameras of today.
我们如何将三维世界转化为大脑可解读的平面图像?答案在于几何与代数——高等数学中一个迷人分支,它通过透视、投影和线性变换来模拟视觉过程。本文探讨视觉背后的数学原理,从进入眼睛的光线到文艺复兴艺术中的消失点,再到今天的数码相机。
1. The Pinhole Camera – A Mathematical Model of the Eye | 针孔相机——眼睛的数学模型
The simplest model of how we see is the pinhole camera. Light rays from a point in the world travel in straight lines, pass through a tiny aperture, and project an inverted image onto a screen. Mathematically, this is a central projection through a point (the pinhole) onto an image plane. If the pinhole is at the origin and the image plane is at distance f (focal length) along the z-axis, a point (X, Y, Z) in 3D is mapped to 2D coordinates:
最简单的视觉模型是针孔相机。世上的点发出的光线沿直线传播,穿过一个小孔,在屏幕上投射出倒立的像。数学上,这是通过一点(针孔)到成像平面的中心投影。若针孔在原点,像平面沿z轴距离f(焦距),三维点(X, Y, Z)映射到二维坐标:
x′ = f × (X / Z), y′ = f × (Y / Z)
This division by Z is crucial – it creates the effect that objects farther away appear smaller. The pinhole model is the foundation of perspective geometry and is widely used in computer vision and 3D rendering.
除以Z是至关重要的——它产生了物体越远显得越小的效果。针孔模型是透视几何的基础,广泛应用于计算机视觉和三维渲染。
2. Similar Triangles – The Core of Size Perception | 相似三角形——大小感知的核心
Why does an object of height H at distance D produce an image of height h? By drawing rays from the top and bottom of the object through the pinhole, we form a pair of similar triangles. The object-to-pinhole distance D and the image-to-pinhole distance f give the proportion:
为什么距离D处高度为H的物体会产生高度为h的像?从物体顶端和底端引射线通过针孔,构成一对相似三角形。物体到针孔距离D与像到针孔距离f给出比例:
h / f = H / D, h = f × (H / D)
Thus the image size is inversely proportional to distance. This simple relationship allows our brain to estimate depth from angular size, and it is the reason parallel lines appear to converge.
因此像的大小与距离成反比。这个简单的关系让大脑能从视角大小估计深度,也是平行线看似汇聚的原因。
3. Vanishing Points – Where Parallel Lines Meet | 消失点——平行线交汇之处
In perspective projection, a set of parallel lines in 3D that are not parallel to the image plane will appear to converge at a single point called the vanishing point. Mathematically, a point at infinity along a direction vector (dx, dy, dz) projects to image coordinates ( f*dx/dz , f*dy/dz ), provided dz ≠ 0. Different directions produce different vanishing points. The horizon line is formed by the vanishing points of all horizontal lines.
在透视投影中,一组在三维空间中平行但不平行于像平面的直线,看上去会汇聚于一点,称为消失点。数学上,沿方向向量(dx, dy, dz)的无穷远点投影到图像坐标 ( f·dx/dz , f·dy/dz ),只要dz ≠ 0。不同方向产生不同的消失点。所有水平线的消失点构成地平线。
This concept is fundamental in art and photography. In a one-point perspective, all depth lines vanish to a single point. In two-point perspective, vertical lines remain parallel, but horizontal lines in two perpendicular directions vanish to two separate points on the horizon.
这一概念在艺术和摄影中非常重要。单点透视中,所有深度线汇聚到一点。两点透视中,垂直线保持平行,但相互垂直的两组水平线分别消失在平线上的两点。
4. Homogeneous Coordinates – A Unifying Framework | 齐次坐标——统一的数学框架
To handle perspective projection elegantly, we use homogeneous coordinates. In this system, a 3D point (X, Y, Z) is represented as a 4-vector (X, Y, Z, 1) and any scalar multiple refers to the same point. The perspective projection can then be written as a matrix multiplication:
为了优雅地处理透视投影,我们使用齐次坐标。在该系统中,三维点(X, Y, Z)表示为四维向量(X, Y, Z, 1),任何标量倍数均表示同一点。透视投影可写为矩阵乘法:
[ x′, y′, z′, w ]ᵀ = P · [ X, Y, Z, 1 ]ᵀ
where the matrix P is typically a 4×4 transformation that includes scaling by f and perspective division. After the multiplication, the final 2D coordinates are obtained by dividing by w: x = x′/w, y = y′/w. This division is precisely what encodes the “divide by Z” effect.
其中矩阵P通常是4×4变换,包含按f缩放和透视除法。乘法后,通过除以w得到最终二维坐标:x = x′/w, y = y′/w。这一除法正是“除以Z”效果的编码。
Using homogeneous coordinates, we can chain together translation, rotation, scaling, and projection into a single matrix – a powerful tool in 3D graphics and computer vision.
利用齐次坐标,我们可以将平移、旋转、缩放和投影串联成一个矩阵——这是三维图形和计算机视觉中的强大工具。
5. The Camera Matrix and Intrinsic Parameters | 相机矩阵与内参数
A real eye or camera involves more than just the pinhole. The image plane may be shifted, the pixels may not be square, and the optical axis may not pass through the centre of the sensor. These properties are captured by the intrinsic matrix K:
真实的眼睛或相机不仅包含针孔。像平面可能有偏移,像素可能非正方形,光轴可能不通过传感器中心。这些性质由内参矩阵K描述:
K = [ f_x, s, c_x; 0, f_y, c_y; 0, 0, 1 ]
Here f_x, f_y are focal lengths in pixel units, c_x, c_y is the principal point (image centre), and s is a skew factor. The full projection equation becomes:
这里f_x, f_y是以像素为单位的焦距,c_x, c_y是主点(像中心),s是扭曲因子。完整的投影方程为:
x = K · [ R | t ] · X_world
where [ R | t ] transforms from world coordinates to camera coordinates. This concise algebraic form is widely used in robotics, augmented reality, and 3D reconstruction.
其中[ R | t ]将世界坐标变换到相机坐标。这个简洁的代数形式广泛应用于机器人学、增强现实和三维重建。
6. Depth Perception and Stereopsis | 深度感知与立体视觉
We perceive depth not only from perspective cues but also from binocular vision. When two eyes (or cameras) view the same scene from slightly different positions, the disparity in the image positions of a point reveals its depth. If the baseline (distance between eyes) is B and the focal length is f, the depth Z of a point can be found from its disparity d = x_left − x_right:
我们不仅通过透视线索感知深度,还通过双眼视觉。当两只眼睛(或相机)从略不同位置看同一场景时,点在图像上的位置差异(视差)揭示其深度。若基线(两眼间距)为B,焦距为f,点的深度Z可由视差d = x_left − x_right求得:
Z = ( f × B ) / d
Larger disparity means the object is closer. This principle underlies 3D movies, stereo cameras, and the human ability to catch a ball in flight. The mathematics here is once again based on similar triangles.
视差越大表示物体越近。这一原理是三维电影、立体相机和人类接住飞行中球类能力的基础。这里的数学再次基于相似三角形。
7. Field of View and Focal Length | 视场与焦距
The angular field of view (FOV) determines how much of the scene is visible. For a given sensor width W and focal length f, the horizontal angle of view θ is related by:
视场角(FOV)决定了能看到多少场景。对给定传感器宽度W和焦距f,水平视角θ满足:
tan(θ/2) = W / (2f)
A shorter focal length gives a wider angle (e.g. wide-angle lens), while a longer focal length narrows the view (telephoto). In human vision, the eye’s effective focal length is about 17 mm, giving a horizontal FOV of roughly 135°.
焦距越短视角越宽(如广角镜头),焦距越长视野越窄(长焦)。人类视觉中,眼球有效焦距约17毫米,提供约135°的水平视场。
8. Orthographic vs. Perspective Projection | 正交投影与透视投影
In some mathematical models, we ignore perspective effects, assuming all projection lines are parallel. This is orthographic projection, used in engineering drawings and some games (e.g. isometric view). The mapping is simply (x, y) = (X, Y), discarding Z. It preserves parallelism but loses depth information.
在某些数学模型中,我们忽略透视效果,假设所有投影线平行。这就是正交投影,用于工程图和某些游戏(如等距视角)。映射关系简化为(x, y) = (X, Y),直接丢弃Z。它保持平行性但丢失深度信息。
Perspective projection, by contrast, provides a realistic sense of depth but distorts shapes. The choice between them depends on the application: orthographic for precise measurement, perspective for immersive experience.
相比之下,透视投影提供真实的深度感但会扭曲形状。两者之间的选择取决于应用:正交投影用于精确测量,透视用于沉浸式体验。
9. Lens Distortion and Mathematical Correction | 镜头畸变与数学校正
Real optical systems introduce nonlinear distortions. Two common types are barrel distortion (image magnification decreases with distance from centre) and pincushion distortion (magnification increases). These aberrations can be modelled by polynomials. For a point at radial distance r from the image centre, the distorted radius r_d is approximated by:
真实光学系统会引入非线性畸变。常见的有桶形畸变(像放大率随距中心距离增大而减小)和枕形畸变(放大率增大)。这些像差可用多项式建模。对于距像中心径向距离为r的点,畸变半径r_d近似为:
r_d = r × (1 + k₁ r² + k₂ r⁴ + k₃ r⁶)
The coefficients k₁, k₂, k₃ characterise the lens. In digital photography and computer vision, these parameters are estimated during camera calibration (e.g. using a checkerboard) and then used to undistort the image, allowing accurate geometric measurements.
系数k₁, k₂, k₃刻画了镜头特征。在数码摄影和计算机视觉中,这些参数通过相机标定(如使用棋盘格)估计,然后用于校正图像,从而实现精确几何测量。
10. From Euclidean Geometry to Projective Geometry | 从欧氏几何到射影几何
The mathematics of how we see leads naturally to projective geometry, where the fundamental invariant is the cross-ratio of four collinear points. In projective space, parallel lines ‘meet’ at points at infinity, which are treated on an equal footing with finite points. This abstraction, pioneered by Poncelet and others, unifies perspective drawing with algebraic geometry. The projective plane is the set of lines through the origin in ℝ³, and transformations that preserve collinearity are projective transformations – represented by 3×3 matrices up to scale.
视觉的数学自然导向射影几何,其基本不变量是四共线点的交比。在射影空间中,平行线“相遇”于无穷远点,这些点与有限点同等对待。这种抽象由Poncelet等人开创,将透视画法与代数几何统一起来。射影平面是ℝ³中过原点的直线集合,保持共线性的变换是射影变换——由3×3矩阵在比例意义下表示。
Understanding this framework deepens one’s appreciation of both classical perspective and modern multi-view geometry.
理解这一框架能加深对古典透视和现代多视图几何的鉴赏。
Published by TutorHao | Further Mathematics Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导