-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
handle color string mapping correctly #4840
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
handle color string mapping correctly #4840
Conversation
Hello @wwymak! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2020-07-12 17:06:02 UTC |
labels = np.zeros((10, 10), dtype=np.int64) | ||
labels[1:3, 1:3] = 1 | ||
labels[6:9, 6:9] = 2 | ||
assert_no_warnings(label2rgb, labels, image=img, bg_label=0, bg_color='red') |
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.
would you mind making the test more specific, like for example testing that one of the background pixels is indeed red? (if it's not too complicated)
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.
hmm, I am not sure it's so easy to test because the background pixels isn't really red in the overlay
mode because of
scikit-image/skimage/color/colorlabel.py
Line 197 in c915109
result = label_to_color[mapped_labels] * alpha 8000 + image * (1 - alpha) |
Or do you think I should plug in the defaults and checked that the background pixel matches the output of that calculation referenced ^^?
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.
assert_no_warnings(label2rgb, labels, image=img, bg_label=0, bg_color='red') | |
output = label2rgb(labels, image=img, bg_label=0, bg_color='red', alpha=0.9) | |
assert output[0, 0, 0] > 200 # red channel |
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.
increasing alpha
makes it easier to test the red color :-)
Very cool @wwymak I think you nailed the bug beautifully! For the |
I don't think so (or at least I didn't see an issue about this when I searched for |
(I am also not sure I understand the failed build so if you can point me towards what needs fixing that would be great) |
Do not worry about that failed build. It is due to an unrelated bug upstream in Matplotlib (matplotlib/matplotlib#17730). |
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 @wwymak looks good to me!
@scikit-image/core this bug-fix PR is ready I think, please review! |
Description
Resolves #4534
I think previously the way the color isn't handled as intended in
_match_label_with_color
because if you pass[color]
into_rgb_vector
it's not dealing with color the way it's intended (you should only pass one color, not a list)Also fixes (I think?) the vector size mismatch in
label2rgb
with kind='avg'Checklist
./doc/examples
(new features only)./benchmarks
, if your changes aren't covered by anexisting benchmark
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.