Fix corruption of an island mask in assign_leftovers - #410
Conversation
| return None, mask | ||
| # Convert 'cc' to a tuple to properly index the 2D numpy array | ||
| mask[tuple(cc)] = True | ||
|
|
There was a problem hiding this comment.
You removed the return statement, which changes the logic of the function. It will now continue into the else branch of if len(belongs) == 1, which is probably not what you want. OTOH, I find the original method confusing in the sense that it either returns None or a list. I'm not sure why it doesn't simply return the unaltered labels in this case, which I think it should. @darafferty, what do you think?
There was a problem hiding this comment.
I agree, I have restored return.
There was a problem hiding this comment.
Yeah, well the question remains if it should return labels, which is provided as input and will most likely not be None, or None as it was. Like I said, I'm confused about the original code, so this might as well be a bug fix.
…mask-in-assign_leftovers
…mask-in-assign_leftovers
…mask-in-assign_leftovers
Mask updating
Replaced the incorrect reassignment (
mask = (mlabels == ii)) with proper in-place pixel masking (mask[tuple(cc)] = True). (There was a commented-out attempt# mask[cc] = Trueindicating the original intent).Loop termination
The return was executed too early, meaning that not all pixels could be processed.