用法:
skimage.segmentation.expand_labels(label_image, distance=1)
通过
distance
像素展开标签图像中的标签而不重叠。给定一个标签图像,
expand_labels
将标签区域(连接的组件)向外增长最多distance
个像素,而不会溢出到相邻区域。更具体地说,每个在欧几里得距离 distance 像素的欧几里得距离内的每个背景像素都被分配了该连接分量的标签。当多个连通分量在背景像素的distance
像素内时,将分配最近连通分量的标签值(有关多个标签等距离的情况,请参见注释)。- label_image:dtype int的ndarray
标签图像
- distance:浮点数
以像素为单位的欧几里得距离,用于增长标签。默认为一。
- enlarged_labels:dtype int的ndarray
标记数组,其中所有连接区域都已放大
参数:
返回:
注意:
在标签间隔超过
distance
像素的情况下,这相当于使用半径为distance
的圆盘或超球进行形态膨胀。然而,与形态扩张相反,expand_labels
不会将标签区域扩展到相邻区域。expand_labels
的这个实现是从 CellProfiler [1] 派生的,它被称为模块“IdentifySecondaryObjects (Distance-N)”[2]。当一个像素到多个区域的距离相同时,存在一个重要的边情况,因为没有定义哪个区域扩展到该空间。在这里,确切的行为取决于
scipy.ndimage.distance_transform_edt
的上游实现。参考:
例子:
>>> labels = np.array([0, 1, 0, 0, 0, 0, 2]) >>> expand_labels(labels, distance=1) array([1, 1, 1, 0, 0, 2, 2])
标签不会相互覆盖:
>>> expand_labels(labels, distance=3) array([1, 1, 1, 1, 2, 2, 2])
在平局的情况下,行为未定义,但目前按字典顺序解析为最接近
(0,) * ndim
的标签。>>> labels_tied = np.array([0, 1, 0, 2, 0]) >>> expand_labels(labels_tied, 1) array([1, 1, 1, 2, 2]) >>> labels2d = np.array( ... [[0, 1, 0, 0], ... [2, 0, 0, 0], ... [0, 3, 0, 0]] ... ) >>> expand_labels(labels2d, 1) array([[2, 1, 1, 0], [2, 2, 0, 0], [2, 3, 3, 0]])
相关用法
- Python skimage.segmentation.active_contour用法及代码示例
- Python skimage.segmentation.relabel_sequential用法及代码示例
- Python skimage.segmentation.flood_fill用法及代码示例
- Python skimage.segmentation.clear_border用法及代码示例
- Python skimage.segmentation.felzenszwalb用法及代码示例
- Python skimage.segmentation.watershed用法及代码示例
- Python skimage.segmentation.find_boundaries用法及代码示例
- Python skimage.segmentation.random_walker用法及代码示例
- Python skimage.segmentation.slic用法及代码示例
- Python skimage.segmentation.flood用法及代码示例
- Python skimage.segmentation.join_segmentations用法及代码示例
- Python skimage.feature.graycomatrix用法及代码示例
- Python skimage.color.lab2lch用法及代码示例
- Python skimage.draw.random_shapes用法及代码示例
- Python skimage.feature.blob_doh用法及代码示例
- Python skimage.feature.blob_dog用法及代码示例
- Python skimage.filters.unsharp_mask用法及代码示例
- Python skimage.registration.optical_flow_tvl1用法及代码示例
- Python skimage.filters.rank.noise_filter用法及代码示例
- Python skimage.exposure.histogram用法及代码示例
注:本文由纯净天空筛选整理自scikit-image.org大神的英文原创作品 skimage.segmentation.expand_labels。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。