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.
add test for #3025
Merge pull request #3033 from thouis/master

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