TAGS :Viewed: 13 - Published at: a few seconds ago

[ Python connected components with pixel list ]

In matlab you can use

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

To get pixel list of each connected components. What's the python equivalent? I tried

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

To get the labels, however, this does not come with pixel list.
Any suggestions?

Answer 1


The regionprops function in scikit-image returns the property "coords", an (N, 2) ndarray coordinate list (row, col) of the region. I ran into the same problem and am using this to get the pixel list from the label array.