morphology.label() bug?

Stéfan van der Walt stefan at sun.ac.za
Sat Dec 17 02:50:01 EST 2011


Hi TJ

On Fri, Dec 16, 2011 at 5:16 PM, karoyakani <tj.takei at gmail.com> wrote:
> lable() of my skimage 0.4.2 generates a wierd label value "2" at the
> bottom-right corner.
>
> 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]])
>
> from skimage import morphology
> morphology.label(a)
>
> Out[]:
> array([
>  [0, 1, 1, 0, 0, 0],
>       [0, 1, 1, 0, 1, 0],
>       [0, 0, 0, 1, 1, 1],
>       [0, 0, 0, 0, 1, 2]])

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]])

> Is this a bug or a feature?
> Documentation virtually tells nothing and no example.

It's a feature, but you are right that the documentation is sloppy!
I've made a pull request to add 4/8 connectivity and update the docs:

https://github.com/scikits-image/scikits-image/pull/105

Regards
Stéfan



More information about the scikit-image mailing list