# 分水岭分割

分水岭分割是数学形态学中的一种图像分割方法，它将像素强度视为地形的高程，把图像划分为由分水岭线隔开的集水盆地。泛洪的起点可以是高程图（通常是图像梯度）的所有区域极小值，也可以是选定的标记。该方法用于一般灰度分割、轮廓检测，以及分离显微图像中的细胞等相互接触的对象。<sup>[1](https://scikit-image.org/docs/0.20.x/user_guide/tutorial_segmentation.html)</sup><sup> • </sup><sup>[2](https://www.mdpi.com/2313-433X/8/5/127)</sup>

| 关键事实 | 详情 |
| --- | --- |
| 输出 | 由分水岭线隔开的一组集水盆地（区域）<sup>[1](https://scikit-image.org/docs/0.20.x/user_guide/tutorial_segmentation.html)</sup> |
| 典型输入 | 形态学梯度或其他高程图，而非原始图像<sup>[3](https://pure.rug.nl/ws/files/127130790/parwshed.pdf)</sup> |
| 复杂度 | 基于泛洪的实现复杂度为 O(N)，N 为图像元素数量，但速度随数据结构的不同而差异很大<sup>[2](https://www.mdpi.com/2313-433X/8/5/127)</sup> |
| 实测速度差异 | 在一个 FIB-SEM 体数据上，从约 0.5 分钟（商业软件 Avizo、IPSDK）到 4.5 小时（最慢的实现）<sup>[2](https://www.mdpi.com/2313-433X/8/5/127)</sup> |
| 主流变体 | 标记控制分水岭，用于抑制过分割<sup>[4](https://doi.org/10.1016/0165-1684%2894%2990060-4)</sup> |
| GPU 速度 | 使用并行分水岭和瀑布算法，在不到 1.4 秒内处理 8 亿体素（2024年）<sup>[5](https://arxiv.org/html/2410.08946)</sup> |
| 主要缺点 | 梯度图像中的伪极小值导致过分割<sup>[6](https://doi.org/10.1109/34.87344)</sup> |

## 工作原理

图像被解读为一幅地形起伏图。起伏图的每个区域极小值都与一组表面点相关联：一滴水从这些表面点出发，可以抵达该极小值；这个集合就是一个集水盆地，相邻盆地的公共点构成分水岭线。<sup>[7](https://people.cmm.minesparis.psl.eu/users/beucher/publi/watershed.pdf)</sup> 从所有极小值同时向起伏图泛洪，便将表面划分开来，使每个像素被归属到一个盆地，或被标记为分水岭线像素；某些实现按惯例分配边界像素。

在实践中，该变换通常不直接作用于原始图像，而是作用于其形态学梯度，从而使分水岭线落在灰度值不连续处，即目标轮廓上。<sup>[3](https://pure.rug.nl/ws/files/127130790/parwshed.pdf)</sup> 泛洪可以形式化为地形距离上的贪心最短距离过程：集水盆地即为区域极小值在该距离下的 Voronoi 镶嵌，其高程设为 0。<sup>[8](https://ar5iv.labs.arxiv.org/html/1204.2134)</sup> 迈耶 1994 年的论文基于这种地形距离给出了分水岭线的严格定义，并从经典最短路径图算法推导出了分水岭算法。<sup>[4](https://doi.org/10.1016/0165-1684%2894%2990060-4)</sup>

## 实现方法

标准的实践流程如下：计算一幅高程图，例如 Sobel 梯度的幅值；定义标记，例如取自图像直方图的极值；从这些标记出发对高程图运行分水岭；然后通过孔洞填充和连通分量标记等操作清理标签图像。<sup>[1](https://scikit-image.org/docs/0.20.x/user_guide/tutorial_segmentation.html)</sup> 高程图的选择对分割质量至关重要。<sup>[1](https://scikit-image.org/docs/0.20.x/user_guide/tutorial_segmentation.html)</sup>

有若干算法家族实现这种泛洪。樊尚和苏瓦耶于 1991 年发表的浸没算法按灰度值递增顺序对像素排序，使用先进先出像素队列逐层模拟泛洪，在每个阈值掩模内将标签扩展为测地影响区；其时间复杂度与像素数量呈线性关系。<sup>[6](https://doi.org/10.1109/34.87344)</sup> 伯谢和迈耶开发了使用优先队列的泛洪算法，其中优先级为图像元素的起伏值。<sup>[2](https://www.mdpi.com/2313-433X/8/5/127)</sup> 图像森林变换（IFT）变体在 O(m+C) 时间内从标记计算最短路径森林，并能处理等高平台。<sup>[9](https://onlinelibrary.wiley.com/doi/10.1111/1467-8659.00495)</sup> 第二种策略称为降雨算法，它模拟从每个像素出发的雨滴，沿最速下降路径直至到达某个区域极小值，被吸引到每个极小值的像素定义了其集水盆地。<sup>[10](https://sci2s.ugr.es/sites/default/files/ficherosPublicaciones/2344_10.1007-978-3-319-62359-7_12.pdf)</sup>

处理速度和复杂度在很大程度上取决于所采用的数据结构：对十种实现在一个 FIB-SEM 体图像上进行基准测试，最快的商业库约 0.5 分钟完成，最慢的实现则耗时 4.5 小时。<sup>[2](https://www.mdpi.com/2313-433X/8/5/127)</sup>

## 起源

费尔南·迈耶和塞尔日·伯谢于 1990 年在《视觉传播与图像表示杂志》上发表了标记控制形态学分割策略，<sup>[11](https://doi.org/10.1016/1047-3203%2890%2990014-m)</sup> 吕克·樊尚和皮埃尔·苏瓦耶于 1991 年在《IEEE 模式分析与机器智能汇刊》上发表了浸没模拟算法，<sup>[6](https://doi.org/10.1109/34.87344)</sup> 费尔南·迈耶于 1994 年在《信号处理》上发表了地形距离定义，<sup>[4](https://doi.org/10.1016/0165-1684%2894%2990060-4)</sup> 理查德·巴恩斯、克拉伦斯·莱曼和大卫·穆拉于 2013 年在《计算机与地球科学》上发表了用于数字高程模型的优先泛洪算法。<sup>[12](https://doi.org/10.1016/j.cageo.2013.04.024)</sup>

关于最早归属，文献中的记述并不一致。分水岭变换最初是作为形态学工具引入的，用于研究沥青路面起伏的排水性，后来由朗特若尔和伯谢推广到灰度情形。<sup>[6](https://doi.org/10.1109/34.87344)</sup> 伯谢和朗特若尔 1979 年的研讨会论文将轮廓定义为梯度模的分水岭，并将该思想应用于射线照相板中的气泡检测和钢中断裂的晶面检测；在其他文献中，该论文被描述为分水岭在分割中的应用。<sup>[7](https://people.cmm.minesparis.psl.eu/users/beucher/publi/watershed.pdf)</sup><sup> • </sup><sup>[13](https://arxiv.org/pdf/1202.0216v1.pdf)</sup> 已发表的文献未能确定 1978 年报告与 1979 年论文之间的优先顺序。<sup>[6](https://doi.org/10.1109/34.87344)</sup>

## 变体

**标记控制分水岭**从选定的一组标记出发，而不是从所有极小值出发，对梯度起伏图进行泛洪。标记是为每个待检测对象（包括背景）指定的内部标记，然后从与标记相同的源进行泛洪；经典实现通过灰度重建将梯度替换为一个函数，使其仅有的区域极小值对应于标记。<sup>[4](https://doi.org/10.1016/0165-1684%2894%2990060-4)</sup> 迈耶还证明了基于标记的泛洪等价于为字典序距离函数构造标记的 Voronoi 镶嵌，即影响骨架。<sup>[14](http://congres.cran.univ-lorraine.fr/2004/ICIP%202004/defevent/papers/cr2474.pdf)</sup>

**层次与随机变体**旨在解决过分割问题。伯谢的瀑布变换将集水盆地抬升至其周围分水岭线最低鞍点高度处的平台，并递归地重新应用分水岭，单调地减少盆地数量；五到七个瀑布层通常能给出语义上有意义的层次结构。<sup>[5](https://arxiv.org/html/2410.08946)</sup> 扩展至轮廓弧段的极小值动态可作为轮廓显著性的度量，产生一个包含所有可通过阈值化动态获得的分割的层次结构。<sup>[15](https://hal.science/hal-00622128/document)</sup> 在随机分水岭中，区域从随机选择的种子生长，种子方案包括非均匀泊松过程以及以距离图极大值为中心的圆盘内随机播种。<sup>[10](https://sci2s.ugr.es/sites/default/files/ficherosPublicaciones/2344_10.1007-978-3-319-62359-7_12.pdf)</sup> 分水岭割按照水滴原理将方法推广到边加权图，并通过一个等价定理与最小生成树相联系，从而与 Kruskal 算法相联系。<sup>[16](https://link.springer.com/article/10.1007/s10851-026-01347-0)</sup>

**距离变换分水岭**用于分离相互接触的对象：对对象的二值掩模进行变换，使每个像素持有其到背景的距离，该距离图的峰成为各个对象的标记，反转距离变换的分水岭将对象切开。OpenCV 基于标记的实现遵循这一方案，结合 Otsu 二值化、形态学开运算、距离变换阈值和膨胀来定义标记与未知带状区域。<sup>[17](https://docs.opencv.org/4.x/d3/db4/tutorial_py_watershed.html)</sup>

## 应用

分水岭分割应用于遥感、医学成像、生物成像和材料科学。<sup>[16](https://link.springer.com/article/10.1007/s10851-026-01347-0)</sup> 已记录的用途包括 MRI 分析、细胞图像分析、制图学和视频。<sup>[10](https://sci2s.ugr.es/sites/default/files/ficherosPublicaciones/2344_10.1007-978-3-319-62359-7_12.pdf)</sup> 在深度学习时代，分水岭仍与神经网络广泛结合使用，通常用于在语义分割步骤之后分离相互接触的对象。<sup>[2](https://www.mdpi.com/2313-433X/8/5/127)</sup> 另一种常见做法是用来自深度网络的轮廓图对图边加权，通常作为学习梯度与局部差异的线性组合。<sup>[16](https://link.springer.com/article/10.1007/s10851-026-01347-0)</sup> [卡森·斯特林格](https://www.edgepedia.org/zh/carsen-stringer)及其同事于 2020 年在《自然-方法》上发表的 Cellpose 等通用细胞分割方法，可作为相同细胞分割任务的监督基线。<sup>[18](https://doi.org/10.1038/s41592-020-01018-x)</sup>

## 局限性与替代方法

**过分割**是经典算法的主要缺点：从含噪梯度的所有极小值进行泛洪会产生许多小盆地，正确轮廓湮没在大量无关轮廓之中。<sup>[6](https://doi.org/10.1109/34.87344)</sup><sup> • </sup><sup>[3](https://pure.rug.nl/ws/files/127130790/parwshed.pdf)</sup> 缓解方法分为预处理和后处理两类：基于标记的预处理是最有效的技术，使用二值标记图像，将对象内部设为 0，不确定区域设为 255；其他选项包括中值滤波、彩色形态学、盆地合并、盆地动态、多尺度梯度分析和层次分水岭。尚无完美的解决方案，这对于血细胞等计数任务尤为重要。<sup>[10](https://sci2s.ugr.es/sites/default/files/ficherosPublicaciones/2344_10.1007-978-3-319-62359-7_12.pdf)</sup>

算法选择也会影响正确性。一项对比分析发现，樊尚-苏瓦耶、迈耶和林算法不能保持重要的拓扑特征，而 洛图福、库普里和库斯蒂的算法从这一角度看是正确的。<sup>[19](https://hal.science/hal-01294109v1/document)</sup> 使用小邻域的经典算法会接受过多陡峭轨迹，产生粗厚的分水岭区和不够精确的轮廓；采用无限深度字典序的最速分水岭表述则消除了这些任意选择。<sup>[8](https://ar5iv.labs.arxiv.org/html/1204.2134)</sup>

与基于割的替代方法相比，分水岭具有结构上的优势：由于它不惩罚分割边界长度，因此不会表现出收缩偏差，这与多终端割或（条件）随机场不同，因而适合神经元等表面积与体积比高的对象。<sup>[20](https://ar5iv.labs.arxiv.org/html/1704.02249)</sup> 顺序处理速度仍然是一个局限，推动了并行实现的发展：并行线性时间分水岭在处理器数量增至 32 个的过程中，加速比持续提高，并消除分水岭线的顺序偏差变形；GPU 元胞自动机实现估计约快十倍，尽管 GPU 内存限制了其可处理的图像尺寸。<sup>[21](https://www.ipol.im/pub/art/2022/215/article.pdf)</sup>

交互式实现允许在不重新计算分割的情况下添加或移除种子，速度提升可达此前高性能库的 95 倍；核外算法可处理超出主存的数据；深度网络也被用于提供基于用户的标记，并生成层次轮廓以产生语义一致的分割层级。<sup>[16](https://link.springer.com/article/10.1007/s10851-026-01347-0)</sup>

## References

1. [Image Segmentation, scikit-image documentation](https://scikit-image.org/docs/0.20.x/user_guide/tutorial_segmentation.html)
2. [A Review of Watershed Implementations for Segmentation of Volumetric Images (J. Imaging 8(5):127, 2022)](https://www.mdpi.com/2313-433X/8/5/127)
3. [The Watershed Transform: Definitions, Algorithms and Parallelization Strategies (Roerdink and Meijster, Fundamenta Informaticae, 2000)](https://pure.rug.nl/ws/files/127130790/parwshed.pdf)
4. [Topographic distance and watershed lines (Signal Processing, 1994)](https://doi.org/10.1016/0165-1684%2894%2990060-4)
5. [Parallel Watershed Partitioning: GPU-Based Hierarchical Image Segmentation (arXiv, October 2024)](https://arxiv.org/html/2410.08946)
6. [L. Vincent, P. Soille (1991). Watersheds in digital spaces: an efficient algorithm based on immersion simulations. IEEE Transactions on Pattern Analysis and Machine Intelligence.](https://doi.org/10.1109/34.87344)
7. [Use of Watersheds in Contour Detection (S. Beucher and C. Lantuejoul, International Workshop on Image Processing: Real-Time Edge and Motion Detection/Estimation, Rennes, 1979)](https://people.cmm.minesparis.psl.eu/users/beucher/publi/watershed.pdf)
8. [The steepest watershed: from graphs to images (Meyer)](https://ar5iv.labs.arxiv.org/html/1204.2134)
9. [Implementation and Complexity of the Watershed-from-Markers Algorithm Computed as a Minimal Cost Forest (Felkel et al., Computer Graphics Forum 2001)](https://onlinelibrary.wiley.com/doi/10.1111/1467-8659.00495)
10. [An Updated Review on Watershed Algorithms (Springer book chapter)](https://sci2s.ugr.es/sites/default/files/ficherosPublicaciones/2344_10.1007-978-3-319-62359-7_12.pdf)
11. [Morphological segmentation (Journal of Visual Communication and Image Representation, 1990)](https://doi.org/10.1016/1047-3203%2890%2990014-m)
12. [Richard Barnes, Clarence Lehman, David Mulla (2013). Priority-flood: An optimal depression-filling and watershed-labeling algorithm for digital elevation models. Computers & Geosciences.](https://doi.org/10.1016/j.cageo.2013.04.024)
13. [The watershed concept and its use in segmentation: a brief history (F. Meyer, arXiv:1202.0216)](https://arxiv.org/pdf/1202.0216v1.pdf)
14. [Morphological segmentation produces a Voronoi tessellation of the markers (F. Meyer, ICIP 2004)](http://congres.cran.univ-lorraine.fr/2004/ICIP%202004/defevent/papers/cr2474.pdf)
15. [Geodesic Saliency of Watershed Contours and Hierarchical Segmentation (Najman and Schmitt, IEEE TPAMI)](https://hal.science/hal-00622128/document)
16. [Playing with Kruskal: A State-of-the-Art Report on Watershed Cuts (Journal of Mathematical Imaging and Vision, Springer)](https://link.springer.com/article/10.1007/s10851-026-01347-0)
17. [Image Segmentation with Watershed Algorithm, OpenCV documentation](https://docs.opencv.org/4.x/d3/db4/tutorial_py_watershed.html)
18. [Carsen Stringer and colleagues (2020). Cellpose: a generalist algorithm for cellular segmentation. Nature Methods.](https://doi.org/10.1038/s41592-020-01018-x)
19. [Watershed approaches in the discrete case (Mahmoudi & Akil, International Journal of Image Processing)](https://hal.science/hal-01294109v1/document)
20. [Learned Watershed: End-to-End Learning of Seeded Segmentation (Turaga et al., arXiv:1704.02249)](https://ar5iv.labs.arxiv.org/html/1704.02249)
21. [A Parallel, O(n) Algorithm for an Unbiased, Thin Watershed (Chabardès et al., IPOL)](https://www.ipol.im/pub/art/2022/215/article.pdf)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Language and vision AI › Computer vision › Vision methods and geometry › Low-level image analysis

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/watershed-segmentation

English original: https://www.edgepedia.org/watershed-segmentation
