Python连接的组件与像素列表

时间:2016-05-10 19:53:36

标签: python image pixels connected-components

在matlab中你可以使用

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

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

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

然而,要获得标签,这不会出现像素列表 有什么建议吗?

2 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:0)

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

pixels = numpy.argwhere(labeled_image == some_label)

请参见numpy.argwhere

另请参阅此similar question