# 数学形态学

数学形态学是一种非线性图像分析理论，其中图像在每个位置用一个小型预定义模式——结构元素——进行探测，并从该模式与图像的拟合方式中提取信息。其核心思想是通过在各种位置将图像与小模式匹配来检查图像的几何结构，从而产生非线性算子而非线性卷积。<sup>[1](https://epubs.siam.org/doi/10.1137/1037001)</sup> 这些算子用于噪声抑制、边缘检测、区域填充、骨架化、编码以及形状表示、平滑和识别。<sup>[2](https://robotics.ntua.gr/wp-content/uploads/sites/2/1986_Maragos_TutorialAdvancesMorphImagProcessAnal_SPIE-0707.pdf)</sup> 该领域应用于矿物学、医学诊断、组织学、遥感、模式识别和计算机视觉。<sup>[3](https://encyclopediaofmath.org/wiki/Mathematical_morphology)</sup>

| 关键事实 | 详情 |
|---|---|
| 核心机制 | 用结构元素探测图像并记录其拟合方式，得到用于滤波、分割和形状分析的非线性算子<sup>[1](https://epubs.siam.org/doi/10.1137/1037001)</sup> |
| 奠基者 | 乔治·马瑟隆（Georges Matheron）和让·塞拉（Jean Serra），他们的工作始于 20 世纪 60 年代枫丹白露（Fontainebleau）的巴黎高等矿业学院（École des Mines de Paris），数学形态学中心（Centre de Morphologie Mathématique）于 1968 年在那里成立；奠基著作包括马瑟隆的《多孔介质理论要素》（*Éléments pour une théorie des milieux poreux*，Masson，1967）<sup>[4](https://perso.telecom-paristech.fr/bloch/papers/HandbookSpatialLogics.pdf)</sup><sup> • </sup><sup>[5](https://people.ciirc.cvut.cz/~hlavac/TeachPresEn/11ImageProc/71-3MatMorpholBinEn.pdf)</sup> |
| 基本算子 | 通过闵可夫斯基（Minkowski）加法和减法进行膨胀和腐蚀；开运算和闭运算是它们幂等的复合<sup>[3](https://encyclopediaofmath.org/wiki/Mathematical_morphology)</sup><sup> • </sup><sup>[6](https://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/MORSE/morph1.pdf)</sup> |
| 理论框架 | 图像空间是完全格；腐蚀和膨胀构成一个伴随<sup>[7](https://ims.nus.edu.sg/wp-content/uploads/2024/03/Isabelle-Bloch_1.pdf)</sup> |
| 快速腐蚀/膨胀 | 范赫尔克（van Herk）算法每像素约需三次比较，基本与结构元素长度无关<sup>[8](https://orbi.uliege.be/bitstream/2268/1302/1/Vandroogenbroeck2005Morphological.pdf)</sup> |
| GPU 软件 | TorchMorph 以融合 CUDA 内核的形式为 PyTorch 张量提供 22 个形态学和距离变换算子<sup>[9](https://doi.org/10.48550/arxiv.2608.24738)</sup> |

## 工作原理

对于二值图像，将其视为点集，膨胀和腐蚀就是闵可夫斯基加法和减法：\( \delta(X) = X \oplus A = \bigcup_{a \in A} X_{a} \) 和 \( \varepsilon(X) = X \ominus A = \bigcap_{a \in A} X_{-a} \)，其中 \( X_{a} = \{x + a: x \in X\} \)。<sup>[3](https://encyclopediaofmath.org/wiki/Mathematical_morphology)</sup> 用 \( B \) 对 \( A \) 进行腐蚀，恰好保留那些对每个 \( b \in B \) 都有 \( x + b \in A \) 的点 \( x \)；膨胀则通过其元素的向量加法来合并集合。<sup>[10](https://haralick.org/journals/04767941.pdf)</sup> 膨胀 \( A \oplus B = \{c \mid c = a + b \text{ 对某些 } a \in A, b \in B\} \) 是可交换且可结合的，因此一个大膨胀可以拆分为连续的小膨胀；腐蚀则两者皆非。<sup>[6](https://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/MORSE/morph1.pdf)</sup>

腐蚀和膨胀构成一个伴随：\( \delta(x) \leq y \Leftrightarrow x \leq \varepsilon(y) \)，从而有 \( \varepsilon\delta \geq \mathrm{Id} \)、\( \delta\varepsilon \leq \mathrm{Id} \)、\( \varepsilon\delta\varepsilon = \varepsilon \) 和 \( \delta\varepsilon\delta = \delta \)。<sup>[7](https://ims.nus.edu.sg/wp-content/uploads/2024/03/Isabelle-Bloch_1.pdf)</sup>

复合运算才是主力：开运算 \( \alpha(X) = X \circ A = (X \ominus A) \oplus A \) 是幂等的且反扩张的，其对偶闭运算 \( \beta(X) = (X \oplus A) \ominus A \) 是幂等的且扩张的；任一运算重复应用时，第一次之后不会再改变任何东西。<sup>[3](https://encyclopediaofmath.org/wiki/Mathematical_morphology)</sup><sup> • </sup><sup>[6](https://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/MORSE/morph1.pdf)</sup> 马瑟隆核表示指出，每个递增平移不变算子都是腐蚀的并（对偶地，是膨胀的交）；MMBB 通用表示理论将其推广到完全格上的任意平移不变递增算子。<sup>[3](https://encyclopediaofmath.org/wiki/Mathematical_morphology)</sup><sup> • </sup><sup>[11](https://arxiv.org/abs/2605.24608)</sup> 对于凸的 \( A \)，模式谱 \( \mathrm{PS}_{X}(r,A) = -\frac{d}{dr}\,\mathrm{area}(X \circ r \cdot A) \)，\( r \geq 0 \)，概括了跨尺度的形状和纹理。<sup>[3](https://encyclopediaofmath.org/wiki/Mathematical_morphology)</sup><sup> • </sup><sup>[12](https://doi.org/10.1109/34.192465)</sup>

## 如何实现

平坦的、基于集合的元素更受青睐，因为它们有高效算法，并且与任何单调递增的图像对比度变换可交换，而体（非平坦）元素则不能。<sup>[13](https://perso.esiee.fr/~talboth/articles/Mine/breen-etal-SandC2000.pdf)</sup> 对于灰度图像 \( f \) 和平坦元素 \( B \)，腐蚀和膨胀是平移上的逐点下确界和上确界，\( \varepsilon_{B}(f) = \bigwedge_{b \in B} f_{-b} \) 和 \( \delta_{B}(f) = \bigvee_{b \in B} f_{b} \)；平坦算子只依赖于像素值的顺序，因此膨胀使亮区扩张、暗区收缩。<sup>[13](https://perso.esiee.fr/~talboth/articles/Mine/breen-etal-SandC2000.pdf)</sup><sup> • </sup><sup>[4](https://perso.telecom-paristech.fr/bloch/papers/HandbookSpatialLogics.pdf)</sup>

朴素计算对于图像大小 \( N \) 和元素大小 \( S \) 的代价为 \( O(N \times S) \)，可降至 \( O(N \times \sqrt{S}) \)、\( O(N \times \log S) \)，或对特定元素降至 \( O(N) \)；测地重建用队列可达到 \( O(N) \)。<sup>[4](https://perso.telecom-paristech.fr/bloch/papers/HandbookSpatialLogics.pdf)</sup> 范赫尔克/吉尔-韦尔曼（van Herk/Gil-Werman，vHGW）算法将每条线分成元素长度的段，向前和向后计算累积最小值或最大值，并以每像素三次比较的固定代价将它们组合起来，基本与元素长度 \( L \) 无关。<sup>[8](https://orbi.uliege.be/bitstream/2268/1302/1/Vandroogenbroeck2005Morphological.pdf)</sup><sup> • </sup><sup>[14](http://leptonica.org/grayscale-morphology.html)</sup><sup> • </sup><sup>[15](https://doi.org/10.1016/0167-8655%2892%2990069-c)</sup>

在软件方面，TorchMorph 提供 22 个公共算子，涵盖二值形态学、灰度形态学和[距离变换](https://www.edgepedia.org/zh/distance-transform)，作为 PyTorch 张量上的融合 CUDA 内核，解决了事实上的 Python 参考实现 scikit-image 仅支持 CPU、单数组设计的问题。<sup>[9](https://doi.org/10.48550/arxiv.2608.24738)</sup> SoftMorph 提供 2D 和 3D 的可微概率滤波器（腐蚀、膨胀、开运算、闭运算、骨架化），并附有集成代码，可将它们用作 nnUNet 分割流水线的最终层。<sup>[16](https://www.eurecom.fr/publication/7927/download/data-publi-7927.pdf)</sup><sup> • </sup><sup>[17](https://github.com/lisaGUZZI/SoftMorph2)</sup>

## 起源

数学形态学的主要概念在著作中阐述（Matheron 1975；Serra 1982；Serra 1988），并且在巴黎高等矿业学院[枫丹白露](https://www.edgepedia.org/zh/fontainebleau)校区的数学形态学中心组建了一个团队。<sup>[4](https://perso.telecom-paristech.fr/bloch/papers/HandbookSpatialLogics.pdf)</sup> 20 世纪 60 年代初，两人从事矿物学和岩相学研究，旨在通过检查几何结构来表征多孔介质的渗透率等物理性质。<sup>[1](https://epubs.siam.org/doi/10.1137/1037001)</sup> 马瑟隆的《多孔介质理论要素》（Masson，1967）和塞拉的《图像分析与数学形态学》（学术出版社（Academic Press），1982）是奠基著作。<sup>[5](https://people.ciirc.cvut.cz/~hlavac/TeachPresEn/11ImageProc/71-3MatMorpholBinEn.pdf)</sup> 该方法最初为随机集上的尺寸变换而开发，随后扩展到函数（塞拉 1982；斯特恩伯格（Sternberg）1986）以及完全格的一般框架（塞拉 1988；龙塞（Ronse）和黑曼斯（Heijmans）1991）。<sup>[13](https://perso.esiee.fr/~talboth/articles/Mine/breen-etal-SandC2000.pdf)</sup> 其底层的集合运算是闵可夫斯基加法和闵可夫斯基减法。<sup>[4](https://perso.telecom-paristech.fr/bloch/papers/HandbookSpatialLogics.pdf)</sup> 罗伯特·M·哈拉利克（Robert M. Haralick）、斯坦利·R·斯特恩伯格（Stanley R. Sternberg）和庄新华（Xinhua Zhuang）的教程（《IEEE 模式分析与机器智能汇刊》，1987）为更广泛的视觉社区形式化了二值和灰度形态学。<sup>[18](https://doi.org/10.1109/tpami.1987.4767941)</sup>

## 变体

灰度形态学将集合算子扩展到函数；保留所有二值关系的通用扩展归功于斯坦利·R·斯特恩伯格，他 1986 年的论文《灰度形态学》发表在《计算机视觉、图形学与图像处理》上。<sup>[19](https://doi.org/10.1016/0734-189x%2886%2990004-6)</sup><sup> • </sup><sup>[10](https://haralick.org/journals/04767941.pdf)</sup> 形态学滤波器按定义是既递增又幂等的算子；开运算和闭运算组合成交替序列滤波器，用于图像恢复和噪声去除。<sup>[5](https://people.ciirc.cvut.cz/~hlavac/TeachPresEn/11ImageProc/71-3MatMorpholBinEn.pdf)</sup><sup> • </sup><sup>[3](https://encyclopediaofmath.org/wiki/Mathematical_morphology)</sup> 粒度测定像筛分用逐级增大的筛网分选岩石那样对图像结构进行尺寸分析：一族使用逐渐增大的凸元素的开运算服从吸收律，开运算度量亮（白）结构的大小，闭运算度量暗结构的大小。<sup>[13](https://perso.esiee.fr/~talboth/articles/Mine/breen-etal-SandC2000.pdf)</sup>

测地算子重建被标记的结构：重建开运算使用标记图像，使得只有与标记相连的连通分量保留下来，从而在去除噪声的同时保留轮廓信息；在经典例子中，对澳大利亚的开运算图像进行重建会去除塔斯马尼亚，因为它太小，无法包含结构元素。<sup>[13](https://perso.esiee.fr/~talboth/articles/Mine/breen-etal-SandC2000.pdf)</sup> 吕克·文森特（Luc Vincent）1993 年关于形态学灰度重建的论文给出了应用和高效算法。<sup>[20](https://doi.org/10.1109/83.217222)</sup> 连通滤波器从文森特的面积滤波器发展为属性滤波器和分量树实现。<sup>[21](https://www.lrde.epita.fr/~theo/papers/geraud.2010.book.pdf)</sup> [分水岭分割](https://www.edgepedia.org/zh/watershed-segmentation)从作为极小值施加的标记出发，对梯度图像进行泛洪。<sup>[13](https://perso.esiee.fr/~talboth/articles/Mine/breen-etal-SandC2000.pdf)</sup> 其他标准变换包括距离变换、骨架（中轴）和击中-击不中变换。<sup>[3](https://encyclopediaofmath.org/wiki/Mathematical_morphology)</sup>

## 应用

数学形态学应用于矿物学、医学诊断、组织学、遥感、模式识别和计算机视觉。<sup>[3](https://encyclopediaofmath.org/wiki/Mathematical_morphology)</sup> 它最初的问题是从几何结构表征材料的物理性质，例如多孔介质的渗透率。<sup>[1](https://epubs.siam.org/doi/10.1137/1037001)</sup> 已演示的流水线包括对图像对象进行尺寸分析、汽车牌照分割，以及航空照片的连通分量滤波。<sup>[13](https://perso.esiee.fr/~talboth/articles/Mine/breen-etal-SandC2000.pdf)</sup>

## 局限与替代方法

开运算和闭运算会使对象与背景之间的边界变形：使用圆盘形元素时，它们会使对象的角变圆，当必须在去除小分量或孔洞的同时保持形状时，这是一个缺点。<sup>[4](https://perso.telecom-paristech.fr/bloch/papers/HandbookSpatialLogics.pdf)</sup> 因为开运算会去除无法包含结构元素平移副本的特征，同时可能修改保留特征的边界，所以选择不当的元素尺寸会去除感兴趣的特征而非噪声；反扩张的开运算去除亮噪声，而闭运算去除暗噪声。<sup>[13](https://perso.esiee.fr/~talboth/articles/Mine/breen-etal-SandC2000.pdf)</sup> 开-闭滤波器不是自对偶的，对亮结构和暗结构给出有偏处理，并且缺乏为灰度图像设计广义形态学滤波器的解析准则。<sup>[2](https://robotics.ntua.gr/wp-content/uploads/sites/2/1986_Maragos_TutorialAdvancesMorphImagProcessAnal_SPIE-0707.pdf)</sup> 相比之下，中值滤波器不是幂等的：重复应用可能持续改变图像，并可能产生振荡而不是稳定结果，而开运算和闭运算一次之后就稳定下来。<sup>[4](https://perso.telecom-paristech.fr/bloch/papers/HandbookSpatialLogics.pdf)</sup>

针对深度学习，最近一种论点认为，构成卷积网络的算子——卷积、ReLU、最大池化、步长卷积和跳跃连接——是适当格上形态学算子的特殊实例或近似，而标准 CNN 层与开运算或闭运算不同，不是幂等的。<sup>[11](https://arxiv.org/abs/2605.24608)</sup> 形态神经网络的主要障碍是 min 和 max 不可微，不适合随机梯度下降；p 卷积（PConv）层根据可训练参数 \( p \) 近似非平坦膨胀、腐蚀或经典卷积，而 S Morph 层也可以学习平坦（二值）结构元素。<sup>[22](https://rhermary.github.io/static/pdfs/Learning_Grayscale_Mathematical_Morphology_with_Sm.pdf)</sup> 形态网络已应用于图像恢复和边缘检测，并被认为比通常的 CNN 更具可解释性，因为学习到的滤波器是形态学算子。<sup>[16](https://www.eurecom.fr/publication/7927/download/data-publi-7927.pdf)</sup>

## References

1. [Mathematical Morphology: A Modern Approach in Image Processing Based on Algebra and Geometry (Heijmans, SIAM Review)](https://epubs.siam.org/doi/10.1137/1037001)
2. [Tutorial on Advances in Morphological Image Processing and Analysis (Maragos, SPIE 1986)](https://robotics.ntua.gr/wp-content/uploads/sites/2/1986_Maragos_TutorialAdvancesMorphImagProcessAnal_SPIE-0707.pdf)
3. [Mathematical morphology - Encyclopedia of Mathematics (entry by H.J.A.M. Heijmans)](https://encyclopediaofmath.org/wiki/Mathematical_morphology)
4. [Chapter 14: Mathematical Morphology (Handbook of Spatial Logics, Bloch)](https://perso.telecom-paristech.fr/bloch/papers/HandbookSpatialLogics.pdf)
5. [Hlaváč et al., Mathematical Morphology, Binary (CTU Prague lecture slides)](https://people.ciirc.cvut.cz/~hlavac/TeachPresEn/11ImageProc/71-3MatMorpholBinEn.pdf)
6. [Lecture 5: Binary Morphology (CVonline, Edinburgh)](https://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/MORSE/morph1.pdf)
7. [Bloch, Mathematical Morphology in Complete Lattices (lecture slides)](https://ims.nus.edu.sg/wp-content/uploads/2024/03/Isabelle-Bloch_1.pdf)
8. [Morphological erosions and openings: Fast algorithms based on anchors (Van Droogenbroeck)](https://orbi.uliege.be/bitstream/2268/1302/1/Vandroogenbroeck2005Morphological.pdf)
9. [Zhao, Kai (2026). TorchMorph: CUDA-accelerated Morphological Transforms. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2608.24738)
10. [Haralick, Sternberg & Zhuang, Image Analysis Using Mathematical Morphology (IEEE Trans. PAMI, 1987)](https://haralick.org/journals/04767941.pdf)
11. [Lattice theory and algebraic models for deep convolutional learning based on mathematical morphology (arXiv, 2026)](https://arxiv.org/abs/2605.24608)
12. [P. Maragos (1989). Pattern spectrum and multiscale shape representation. IEEE Transactions on Pattern Analysis and Machine Intelligence.](https://doi.org/10.1109/34.192465)
13. [Mathematical morphology: a useful set of tools for image analysis (Breen, Soille, Talbot)](https://perso.esiee.fr/~talboth/articles/Mine/breen-etal-SandC2000.pdf)
14. [Grayscale Morphology (Leptonica)](http://leptonica.org/grayscale-morphology.html)
15. [A fast algorithm for local minimum and maximum filters on rectangular and octagonal kernels (Pattern Recognition Letters, 1992)](https://doi.org/10.1016/0167-8655%2892%2990069-c)
16. [SoftMorph: Differentiable Probabilistic Morphological Filters (Eurecom publication)](https://www.eurecom.fr/publication/7927/download/data-publi-7927.pdf)
17. [lisaGUZZI/SoftMorph2 (software repository)](https://github.com/lisaGUZZI/SoftMorph2)
18. [Robert M. Haralick, Stanley R. Sternberg, Xinhua Zhuang (1987). Image Analysis Using Mathematical Morphology. IEEE Transactions on Pattern Analysis and Machine Intelligence.](https://doi.org/10.1109/tpami.1987.4767941)
19. [Grayscale morphology (Computer Vision Graphics and Image Processing, 1986)](https://doi.org/10.1016/0734-189x%2886%2990004-6)
20. [L. Vincent (1993). Morphological grayscale reconstruction in image analysis: applications and efficient algorithms. IEEE Transactions on Image Processing.](https://doi.org/10.1109/83.217222)
21. [Algorithms for Mathematical Morphology (Géraud, book chapter)](https://www.lrde.epita.fr/~theo/papers/geraud.2010.book.pdf)
22. [Learning Grayscale Mathematical Morphology with Smooth Morphological Layers (author-hosted paper)](https://rhermary.github.io/static/pdfs/Learning_Grayscale_Mathematical_Morphology_with_Sm.pdf)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026; Oct 21, 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/mathematical-morphology

English original: https://www.edgepedia.org/mathematical-morphology
