Python连接组件与像素列表

问题描述 投票:2回答:2

在matlab中你可以使用

cc = bwconncomp(bimg);
pixels = cc.PixelIdxList{i}

获取每个连接组件的像素列表。什么是python等价物?我试过了

from skimage import measure
label = measure.label(bimg)

然而,要获得标签,这不包括像素列表。 有什么建议?

python image pixels connected-components
2个回答
2
投票

scikit-image中的regionprops函数返回属性“coords”,该区域的(N,2)ndarray坐标列表(row,col)。我遇到了同样的问题,并使用它从标签数组中获取像素列表。


0
投票

要获得带有some_label的连接组件的像素列表(例如some_label = 1),如果您有带标签的图像:

pixels = numpy.argwhere(labeled_image == some_label)

numpy.argwhere

并且还看到这个similar question

© www.soinside.com 2019 - 2024. All rights reserved.