morphology.label() bug?

karoyakani tj.takei at gmail.com
Sat Dec 17 22:36:17 EST 2011



On Dec 17, 3:27 am, Stéfan van der Walt <ste... at sun.ac.za> wrote:
> On Sat, Dec 17, 2011 at 3:13 AM, Emmanuelle Gouillart
>
> <emmanuelle.gouill... at nsup.org> wrote:
> >> > a = np.array([
> >> >    [0,1,1,0,0,0],
> >> >    [0,1,1,0,1,0],
> >> >    [0,0,0,1,1,1],
> >> >    [0,0,0,0,1,0]])
>
> >> This is the correct output, since the zero is not connected to any
> >> other region.    In fact, ndimage labels it incorrectly as:
>
> >> array([[0, 1, 1, 0, 0, 0],
> >>        [0, 1, 1, 0, 1, 0],
> >>        [0, 0, 0, 1, 1, 1],
> >>        [0, 0, 0, 0, 1, 0]])
>
> > Well, this is not incorrect, since ndimage.label only labels connected
> > components of the foreground (True pixels).
>
> Right, so zero is a magical value.  I guess it's pretty easy to get
> the same out of our implementation by simply masking out all
> uninteresting values, and calling "unique" to get the remaining
> labels?

It's very useful and common that we assume Background:="0"-value
pixels.
ndimage and matlab do so.
I don't know why skimage doesn't.

Regarding connectedness, both matlab and ndimage have options of 8-
connect and 4-connect.
Meantime skimage has only 8-connect.
Why don't we add 4-connect as an option?

Regarding number of labeled regions (not counting the background
regions), again matlab and ndimage compute and return it.
Why don't we add it to the skimage, as it would be very useful to
users?
I suspect the reason why the skimage doesn't is because it currently
has a vague notion on the background regions, isn't it?

Regards,
TJ





More information about the scikit-image mailing list