-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support nD images and labels in label2rgb #5550
Support nD images and labels in label2rgb #5550
Conversation
Hello @Abhinavmishra8960! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-09-10 17:10:49 UTC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Abhinavmishra8960. What you have here looks okay, but we will be better off making this function support nD. Please see my suggestion on how we can do this with very little work!
After applying that change this would need:
1.) Update the PR title to something like: Add nD support to label2rgb
2.) Add a new test case to skimage/color/tests/test_colorlabel.py
with 3D (maybe 1D as well) input.
3.) Update the Parameters section of the docstring in this function to remove reference to "2D".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of my prior suggestions caused failures when image
was grayscale (:frowning_face:). The new suggestions here fix that and expand the test cases.
Co-authored-by: Gregory R. Lee <[email protected]>
Co-authored-by: Gregory R. Lee <[email protected]>
Co-authored-by: Gregory R. Lee <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to push one fix to the suggested test case. When I took the 1D slice, it was originally only passing through one of the two labels, which resulted in a mismatch in the label color. I updated the label map used in the tests to have both label values intersect the 1D slice.
Assuming the tests pass now, this is ready to go.
skimage/color/colorlabel.py
Outdated
Integer array of labels with the same shape as `image`. | ||
image : array, shape (M, N) or (..., 3, ...), optional | ||
image : array, shape (M, N) or (M, N, ...., 3), optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing this change, I wonder if shouldn't add the support for the channel_axis
argument...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function does have channel_axis
already! I think the question is how to best indicate that labels is "nD spatial" while image is either "nD spatial" or "nD spatial with channels"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the docstring as currently written implies that channels are in the last position if present, which may be misleading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to remove the shapes from the label
and image
variables type and specify in the description that image
should have the same shape as label
with an optional additional RGB channel axis...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a pushed a commit with the suggested update. please review
Thank you @Abhinavmishra8960 @grlee77! |
#5501
As label2rgb do not support dimension greater than 2. Added Correct error condition and message.
Changed code image
Please do mention changes required.
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.