python 的skimage库中的measure.label可用于标记不同连通域,从而方便图像分析
skimage.measure.label(label_image, background=None, return_num=False, connectivity=None)
源码如下:
@deprecate_kwarg({
"input": "label_image"}, removed_version="1.0")
def label(label_image, background=None, return_num=False, connectivity=None):
r"""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 a
pixel/voxel a neighbor::
1-connectivity 2-connectivity diagonal connection close-up
[ ] [ ] [ ] [ ] [ ]
| \ | / | <- hop 2
[ ]--[x]--[ ] [ ]--[x]--[ ] [x]--[ ]
| / | \ hop 1
[ ] [ ] [ ] [ ]
Parameters
----------
label_image : ndarray of dtype int
Image to label.
background : int, optional
Consider all pixels with this value as background pixels, and label

本文介绍了如何使用skimage.measure.label函数在Python中对图像进行连通域标记,演示了如何定义背景、选择连接方式,并通过实例展示了如何处理不同类型的输入数据。此功能对于图像处理和分析至关重要,例如在计算机视觉和机器学习任务中区分不同的对象区域。
最低0.47元/天 解锁文章
3978

被折叠的 条评论
为什么被折叠?



