用法:
skimage.morphology.label(label_image, background=None, return_num=False, connectivity=None)
标记整数数组的连接区域。
当两个像素是相邻的并且具有相同的值时,它们是连接的。在 2D 中,它们可以是 1 或 2 连接意义上的邻居。该值是指将像素/体素视为邻居的最大正交跳数:
1-connectivity 2-connectivity diagonal connection close-up [ ] [ ] [ ] [ ] [ ] | \ | / | <- hop 2 [ ]--[x]--[ ] [ ]--[x]--[ ] [x]--[ ] | / | \ hop 1 [ ] [ ] [ ] [ ]
- label_image:dtype int的ndarray
要标记的图像。
- background:int 可选
将具有此值的所有像素视为背景像素,并将它们标记为 0。默认情况下,将 0 值像素视为背景像素。
- return_num:布尔型,可选
是否返回分配标签的数量。
- connectivity:int 可选
将像素/体素视为邻居的最大正交跳数。接受的值范围从 1 到 input.ndim 如果
None
,则使用input.ndim
的完整连接。
- labels:dtype int的ndarray
标记数组,其中所有连接区域都分配有相同的整数值。
- num:int 可选
标签数,等于最大标签索引,仅在return_num 为 True 时返回。
- input:DEPRECATED
已弃用以支持label_image。
参数:
返回:
其他参数:
参考:
- 1
Christophe Fiorio and Jens Gustedt, “Two linear time Union-Find strategies for image processing”, Theoretical Computer Science 154 (1996), pp. 165-181.
- 2
Kensheng Wu, Ekow Otoo and Arie Shoshani, “Optimizing connected component labeling algorithms”, Paper LBNL-56864, 2005, Lawrence Berkeley National Laboratory (University of California), http://repositories.cdlib.org/lbnl/LBNL-56864
例子:
>>> import numpy as np >>> x = np.eye(3).astype(int) >>> print(x) [[1 0 0] [0 1 0] [0 0 1]] >>> print(label(x, connectivity=1)) [[1 0 0] [0 2 0] [0 0 3]] >>> print(label(x, connectivity=2)) [[1 0 0] [0 1 0] [0 0 1]] >>> print(label(x, background=-1)) [[1 2 2] [2 1 2] [2 2 1]] >>> x = np.array([[1, 0, 0], ... [1, 1, 5], ... [0, 0, 0]]) >>> print(label(x)) [[1 0 0] [1 1 2] [0 0 0]]
相关用法
- Python skimage.morphology.local_maxima用法及代码示例
- Python skimage.morphology.local_minima用法及代码示例
- Python skimage.morphology.h_minima用法及代码示例
- Python skimage.morphology.dilation用法及代码示例
- Python skimage.morphology.remove_small_holes用法及代码示例
- Python skimage.morphology.flood_fill用法及代码示例
- Python skimage.morphology.black_tophat用法及代码示例
- Python skimage.morphology.h_maxima用法及代码示例
- Python skimage.morphology.area_closing用法及代码示例
- Python skimage.morphology.max_tree_local_maxima用法及代码示例
- Python skimage.morphology.thin用法及代码示例
- Python skimage.morphology.flood用法及代码示例
- Python skimage.morphology.diameter_closing用法及代码示例
- Python skimage.morphology.remove_small_objects用法及代码示例
- Python skimage.morphology.reconstruction用法及代码示例
- Python skimage.morphology.erosion用法及代码示例
- Python skimage.morphology.diameter_opening用法及代码示例
- Python skimage.morphology.max_tree用法及代码示例
- Python skimage.morphology.medial_axis用法及代码示例
- Python skimage.morphology.skeletonize用法及代码示例
注:本文由纯净天空筛选整理自scikit-image.org大神的英文原创作品 skimage.morphology.label。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。