BUG: make ndimage.label properly merge adjacent objects (fixes #3025) #3033

Merged
merged 2 commits into from Nov 9, 2013

Conversation

Projects
None yet
4 participants
Contributor

thouis commented Oct 30, 2013

ndimage.label() uses a table of label values that should be merged in
a postprocess. The logic updating this table was faulty. In
particular, if objects A and B were to be marked for mergin, having
already been marked to merge to C and D, respectively, the implied
merge of C and D was not being inferred.

BUG: make ndimage.label properly merge adjacent objects (fixes #3025)
ndimage.label() uses a table of label values that should be merged in
a postprocess.  The logic updating this table was faulty.  In
particular, if objects A and B were to be marked for mergin, having
already been marked to merge to C and D, respectively, the implied
merge of C and D was not being inferred.

Coverage Status

Coverage remained the same when pulling 04a2dda on thouis:master into bb608ba on scipy:master.

Contributor

juliantaylor commented Nov 6, 2013

please also add a test for this issue

Contributor

thouis commented Nov 6, 2013

I haven't found one besides the original, large image that was posted (44K). Should I write a test based on that image?

Contributor

juliantaylor commented Nov 6, 2013

this reproduces a wrong result:

from scipy import ndimage
d = np.zeros((60,320))
d[:,:257] = 1
d[:,260:] = 1
d[36,257] = 1
d[35,258] = 1
d[35,259] = 1
assert ndimage.label(d, np.ones((3,3)))[1] == 1
Contributor

thouis commented Nov 6, 2013

Done. Thanks for the test case.

Coverage Status

Coverage remained the same when pulling 52d8aff on thouis:master into bb608ba on scipy:master.

pv added a commit that referenced this pull request Nov 9, 2013

Merge pull request #3033 from thouis/master
BUG: make ndimage.label properly merge adjacent objects (fixes #3025)

@pv pv merged commit 6e38760 into scipy:master Nov 9, 2013

1 check passed

default The Travis CI build passed
Details
Owner

pv commented Nov 9, 2013

Thanks, looks good to me.

Contributor

juliantaylor commented Nov 9, 2013

this is a pretty serious bug in a central function of ndimage
it might warrant a 0.13.1

Contributor

thouis commented Nov 9, 2013

+1. (And sorry for the mishap)

Owner

pv commented Nov 9, 2013

I agree, #3049

@pv pv referenced this pull request Nov 9, 2013

Merged

Backport #3033 to 0.13.x #3050

rgommers added a commit that referenced this pull request Nov 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment