# 霍夫变换

霍夫变换是计算机视觉中的一种特征提取技术，它让每个边缘点为所有可能经过该点的形状参数值投票，然后从参数空间中累加器数组的峰值读出形状参数，从而检测图像中的直线、圆和椭圆等形状。1962年，布鲁克黑文国家实验室的保罗·V·C·霍夫为一种识别气泡室照片中粒子径迹的方法获得了专利，此后它一直是图像分析中应用最广泛的直线检测方法之一。<sup>[1](https://patents.google.com/patent/US3069654A/en)</sup><sup> • </sup><sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC6308381/)</sup>

| 关键事实 | 详情 |
|---|---|
| 起源 | 美国专利3,069,654，“识别复杂图形的方法与装置”，1960年提交申请，1962年12月18日授予保罗·V·C·霍夫，用于气泡室照片的机器分析<sup>[1](https://patents.google.com/patent/US3069654A/en)</sup><sup> • </sup><sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC6308381/)</sup> |
| 关键重构 | 杜达与哈特（《美国计算机学会通讯》，1972年）用角度—半径（法向）参数取代了斜率—截距参数，简化了计算<sup>[3](https://ntrs.nasa.gov/search.jsp?R=19720033498)</sup> |
| 直线方程 | 直线写作 \( \rho = x \cdot \cos\theta + y \cdot \sin\theta \)，其中 \( \rho \) 为原点到直线的垂直距离，\( \theta \) 为法线的角度<sup>[4](https://docs.opencv.org/4.6.0/d9/db0/tutorial_hough_lines.html)</sup> |
| 机制 | 每个边缘点为所有经过它的直线投票；得票最多的累加器单元给出检测到的直线<sup>[5](https://watkins.cs.queensu.ca/~jstewart/457/notes/22/22-hough-transform.html)</sup> |
| 代价随规模增长 | 若有 \( n \) 个参数、每个参数量化为 \( m \) 个区间，则累加器有 \( m^{n} \) 个元素；圆需要三个参数，因此代价随形状复杂度急剧上升<sup>[6](https://www.sciencedirect.com/science/article/pii/S0031320314003446)</sup><sup> • </sup><sup>[7](https://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm)</sup> |
| 优点 | 能容忍特征边界上的缺口，且相对不受图像噪声影响<sup>[7](https://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm)</sup> |
| 标准实现 | OpenCV提供标准（HoughLines）、概率式（HoughLinesP）、加权式以及霍夫梯度（圆）等变体<sup>[8](https://docs.opencv.org/4.x/d9/db0/tutorial_hough_lines.html)</sup> |

## 工作原理

该变换利用了曲线上的点与该曲线参数之间的对偶性。对于直线检测，图像首先被简化为一系列边缘点，通常由Canny、Sobel或Roberts Cross等边缘检测器完成，生成二值边缘图。<sup>[7](https://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm)</sup>每个边缘点 \( (x_{i}, y_{i}) \) 都位于无穷多条直线上。采用法向（极坐标）参数化，经过该点的每条直线都满足

\[ \rho = x_{i} \cdot \cos\theta + y_{i} \cdot \sin\theta \]

因此随着 \( \theta \) 变化，该点在 \( (\rho, \theta) \) 参数平面上描出一条正弦曲线。<sup>[4](https://docs.opencv.org/4.6.0/d9/db0/tutorial_hough_lines.html)</sup>图像中共线的点产生的正弦曲线会相交于同一个 \( (\rho, \theta) \) 点，该点即记录着它们共同所在直线的参数。<sup>[4](https://docs.opencv.org/4.6.0/d9/db0/tutorial_hough_lines.html)</sup>

**投票与累加。** 参数空间被量化为有限个累加器单元。对每个边缘点，其正弦曲线经过的单元计数加一；所有点处理完毕后，累加器数组中的峰值就为图像中存在相应直线提供了有力证据。<sup>[7](https://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm)</sup>在一个限于16个直线方向、只有三个像素的简单例子中，一条直线得到三票，其他每条直线只得到一票，于是得三票的直线作为最可能的直线被输出。<sup>[5](https://watkins.cs.queensu.ca/~jstewart/457/notes/22/22-hough-transform.html)</sup>随后提取峰值，通常的做法是先做阈值处理，再对累加器图像中的亮簇做细化。<sup>[7](https://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm)</sup>

法向参数化之所以重要，是因为朴素的斜截式 \( y = a \cdot x + b \) 对垂直线失效——此时斜率无界；而 \( (\rho, \theta) \) 形式使参数空间保持有限。<sup>[9](https://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/OWENS/LECT6/node3.html)</sup>杜达与哈特1972年的论文正是论证了这一点，表明角度—半径参数比霍夫最初的斜率—截距方案简化了计算。<sup>[3](https://ntrs.nasa.gov/search.jsp?R=19720033498)</sup>

## 直线之外：圆与任意形状

同样的投票原理可推广到任何具有已知参数方程的图形。圆需要三个参数，即圆心坐标 \( (x_{center}, y_{center}) \) 和半径 \( r \)，因此累加器变为三维，计算代价也相应上升；一般而言，计算量和累加器规模随参数个数呈多项式增长，这使经典技术局限于简单曲线。<sup>[10](https://docs.opencv.org/3.3.0/d4/d70/tutorial_hough_circle.html)</sup><sup> • </sup><sup>[7](https://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm)</sup>OpenCV的圆检测器采用两阶段霍夫梯度法，先从边缘信息中找出候选圆心，再为每个圆心确定最佳半径，以提高效率。<sup>[10](https://docs.opencv.org/3.3.0/d4/d70/tutorial_hough_circle.html)</sup>

**广义霍夫变换。** 1981年，[罗切斯特大学](https://www.edgepedia.org/zh/university-of-rochester)的达纳·H·巴拉德证明，可以从任意非解析形状的轮廓出发，建立从图像空间到霍夫空间的映射，用由原型形状导出的查找表代替参数方程。这使得广义霍夫变换可用于任意复杂的形状，包括组合物体。<sup>[11](https://www.sciencedirect.com/science/article/pii/0031320381900091)</sup><sup> • </sup><sup>[7](https://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm)</sup>

## 计算代价与概率式变体

该方法的主要弱点是代价。每个边缘点要为许多参数组合投票，因此对杜达—哈特算法而言，递增阶段对 \( M \) 个边缘点和 \( N_{\theta} \) 个角度区间需要 \( O(M \cdot N_{\theta}) \) 次运算，峰值搜索在累加器上需要 \( O(N_{\rho} \cdot N_{\theta}) \) 次运算；在典型图像中，递增阶段占主导地位。<sup>[12](https://freddy.cs.technion.ac.il/wp-content/uploads/2018/01/A-PROBABILISTIC-HOUGH-TRANSFORM.pdf)</sup>一项综述统计了超过2500篇关于其变体、推广和应用的论文，提高速度和减少内存占用是反复出现的核心主题。<sup>[6](https://www.sciencedirect.com/science/article/pii/S0031320314003446)</sup>

**概率霍夫变换。** 以色列理工学院的基里亚蒂、埃尔达和布鲁克斯坦于1991年证明，如果只取边缘点中一个小的随机子集作为输入，性能往往只略有下降，而执行时间大大缩短；他们的分析发现，所用点的比例存在一个陡峭的阈值，低于该阈值检测效果会迅速恶化。<sup>[12](https://freddy.cs.technion.ac.il/wp-content/uploads/2018/01/A-PROBABILISTIC-HOUGH-TRANSFORM.pdf)</sup>OpenCV的HoughLinesP实现了一种基于马塔斯、加兰博什和基特勒工作的渐进概率方法，直接返回线段端点 \( (x_{1}, y_{1}, x_{2}, y_{2}) \)，而非无限直线的参数，并提供最小线段长度和最大允许间隙的参数。<sup>[8](https://docs.opencv.org/4.x/d9/db0/tutorial_hough_lines.html)</sup>

**连通性。** 另一个局限是投票方案没有考虑支撑边缘点是否连通。在纹理丰富或有噪声的图像中，累加器峰值可能汇集许多彼此分离、并不构成可感知直线的点，而短线段产生的峰值很小，难以识别。强制连通性的变体通过只统计位于逐渐增大的邻域内、且位置和方向与候选线段一致的边缘点的贡献来解决这一问题。<sup>[13](https://arxiv.org/abs/1109.3637)</sup>

## 应用

由于该变换能容忍缺口和噪声，凡是需要从不完美的边缘数据中恢复直线或曲线结构的地方都会用到它：检测雾障场景中的建筑边缘、在遥感影像中寻找街道、从Canny边缘图中识别遮挡矩形的八条边。<sup>[7](https://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm)</sup>在医学领域，对颈动脉超声图像作霍夫变换分割，在十名正常受试者的纵切和横切面上报告的特异度和准确率均高于0.96。<sup>[14](https://www.sciencedirect.com/science/article/abs/pii/S0301562907002700)</sup>在物理学中，该变换被用于搜索引力波探测器数据的时间—频率平面，以寻找旋转中子星发出的连续波信号，也被用于重建漂移室中的粒子径迹，这又回到了最初促成该专利的气泡室问题。<sup>[15](https://arxiv.org/abs/gr-qc/0407001)</sup><sup> • </sup><sup>[16](https://arxiv.org/abs/physics/0201071)</sup>驾驶辅助中的车道与道路标志识别是一个主要应用领域，不过关于线性霍夫车道检测的研究记录了在不同道路类型、天气、阴影和光照变化下的感知失败案例。<sup>[17](https://journals.sagepub.com/doi/10.1177/17298814211008752)</sup>

**与深度学习的关系。** 近期的工作将该变换嵌入神经网络。深度霍夫变换沿候选直线聚合卷积特征并将其映射到参数域，于是检测图像中的语义直线就归结为寻找参数空间中的峰值响应；该方法以每秒49帧运行，在语义直线基准上优于此前的方法。<sup>[18](https://arxiv.org/abs/2003.04676)</sup><sup> • </sup><sup>[19](https://kaizhao.net/publications/tpami2021line.pdf)</sup>

## References

1. [US3069654A – Method and means for recognizing complex patterns, P. V. C. Hough, Google Patents](https://patents.google.com/patent/US3069654A/en)
2. [Hough Transform Implementation for Event-Based Systems: Concepts and Challenges, PMC](https://pmc.ncbi.nlm.nih.gov/articles/PMC6308381/)
3. [Use of the Hough transformation to detect lines and curves in pictures, Duda & Hart, NASA NTRS](https://ntrs.nasa.gov/search.jsp?R=19720033498)
4. [OpenCV: Hough Line Transform (4.6.0)](https://docs.opencv.org/4.6.0/d9/db0/tutorial_hough_lines.html)
5. [CISC 457 – Hough Transform, Queen's University](https://watkins.cs.queensu.ca/~jstewart/457/notes/22/22-hough-transform.html)
6. [A survey of Hough Transform, Mukhopadhyay & Chaudhuri, Pattern Recognition 48(3), 2015](https://www.sciencedirect.com/science/article/pii/S0031320314003446)
7. [Image Transforms – Hough Transform, HIPR2, University of Edinburgh](https://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm)
8. [OpenCV: Hough Line Transform (4.x)](https://docs.opencv.org/4.x/d9/db0/tutorial_hough_lines.html)
9. [The Hough Transform, CVonline, University of Edinburgh](https://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/OWENS/LECT6/node3.html)
10. [OpenCV: Hough Circle Transform (3.3.0)](https://docs.opencv.org/3.3.0/d4/d70/tutorial_hough_circle.html)
11. [Generalizing the Hough transform to detect arbitrary shapes, D. H. Ballard, Pattern Recognition 13(2), 1981](https://www.sciencedirect.com/science/article/pii/0031320381900091)
12. [A probabilistic Hough transform, Kiryati, Eldar & Bruckstein, Pattern Recognition 24(4), 1991](https://freddy.cs.technion.ac.il/wp-content/uploads/2018/01/A-PROBABILISTIC-HOUGH-TRANSFORM.pdf)
13. [Connectivity-Enforcing Hough Transform for the Robust Extraction of Line Segments, arXiv](https://arxiv.org/abs/1109.3637)
14. [Using the Hough Transform to Segment Ultrasound Images of the Carotid Artery, Ultrasound in Medicine & Biology 33(12), 2007](https://www.sciencedirect.com/science/article/abs/pii/S0301562907002700)
15. [The Hough transform search for continuous gravitational waves, Krishnan et al., arXiv](https://arxiv.org/abs/gr-qc/0407001)
16. [Implementation of the Hough Transform for 3D Track Reconstruction in Drift Chambers, arXiv](https://arxiv.org/abs/physics/0201071)
17. [Practical limitations of lane detection algorithm based on Hough transform in challenging scenarios, Huang & Liu, 2021](https://journals.sagepub.com/doi/10.1177/17298814211008752)
18. [Deep Hough Transform for Semantic Line Detection, arXiv](https://arxiv.org/abs/2003.04676)
19. [Deep Hough Transform for Semantic Line Detection, TPAMI 2022 (PDF)](https://kaizhao.net/publications/tpami2021line.pdf)

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

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Language and vision AI › Computer vision › Vision methods and geometry › Feature detection and description

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/hough-transform

English original: https://www.edgepedia.org/hough-transform
