|
http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.label
label的函数的功能是根据相邻情况从左到右 从上到下划分区域,并对区域建立索引。
skimage.morphology.
label
(input, neighbors=None, background=None, return_num=False, connectivity=None)[source]Label connected regions of an integer array.
Two pixels are connected when they are neighbors and have the same value.In 2D, they can be neighbors either in a 1- or 2-connected sense.The value refers to the maximum number of orthogonal hops to consider apixel/voxel a neighbor:
1-connectivity2-connectivitydiagonalconnectionclose-up[][][][][]| \ |/|<-hop2[]--[x]--[][]--[x]--[][x]--[]|/| \ hop1[][][][]
Parameters: | input : ndarray of dtype int
neighbors : {4, 8}, int, optional
background : int, optional
return_num : bool, optional
connectivity : int, optional
|
---|---|
Returns: | labels : ndarray of dtype int
num : int, optional
|
See also
regionprops
References
[R726727] | Christophe Fiorio and Jens Gustedt, “Two linear time Union-Findstrategies for image processing”, Theoretical Computer Science154 (1996), pp. 165-181. |
[R727727] | Kensheng Wu, Ekow Otoo and Arie Shoshani, “Optimizing connectedcomponent labeling algorithms”, Paper LBNL-56864, 2005,Lawrence Berkeley National Laboratory (University of California),http://repositories.cdlib.org/lbnl/LBNL-56864 |
Examples
>>> importnumpyasnp>>> 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]]
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-14 13:19
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社