Re: morphology.label() bug?
On Sat, Dec 17, 2011 at 7:36 PM, karoyakani <tj.takei@gmail.com> wrote:
On Dec 17, 3:27 am, Stéfan van der Walt <ste...@sun.ac.za> wrote:
On Sat, Dec 17, 2011 at 3:13 AM, Emmanuelle Gouillart
<emmanuelle.gouill...@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?
Actually, I've always found the return values for `ndimage.label` to be surprising. Every time I use it, I expect to just get the labeled array. Isn't the number of labeled regions equal to the max value of the labeled array? -Tony
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
participants (1)
-
Tony Yu