-
-
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
WIP: Turn off relabelling in label2rgb #3015
base: main
Are you sure you want to change the base?
Conversation
This warning appears to have been adopted in scikit-image#485 with no discussion at all. imho it is unnecessary: if we want to support negative intensity, we should do it correctly (fixing the intensity), rather than raising a warning and doing nothing (since the function silently succeeds). Refs: scikit-image#485
Can turn off relabelling to consecutive labels before color matching. Addresses issue scikit-image#2674
Hello @jni! Thanks for submitting the PR.
|
@@ -0,0 +1,14 @@ | |||
class DefaultValue(object): |
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.
Use Ellipsis instead of None?
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.
Good suggestion, 👍
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.
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.
As I see it, use Ellipsis instead of 'None' in this class. Your option would work equally well, though
@jni. I postponed your PR to 0.17. Perhaps you can have a quick look to check the status of it? :) |
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 think this a good change 👍. Added some points to discuss.
|
||
Returns | ||
------- | ||
result : array of float, shape (M, N, 3) | ||
The result of blending a cycling colormap (`colors`) for each distinct | ||
value in `label` with the image, at a certain alpha value. | ||
""" | ||
if image is None and kind in ['avg' or 'average']: |
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.
if image is None and kind in ['avg' or 'average']: | |
if image is None and kind in ('avg', 'average'): |
Returns | ||
------- | ||
result : array of float, shape (M, N, 3) | ||
result : array of float, shape (M, N,[[ P,] ...,] 3) |
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.
result : array of float, shape (M, N,[[ P,] ...,] 3) | |
result : array of float, shape (M, N,[ P, [...,]] 3) |
@@ -75,7 +79,9 @@ def _match_label_with_color(label, colors, bg_label, bg_color): | |||
|
|||
|
|||
def label2rgb(label, image=None, colors=None, alpha=0.3, | |||
bg_label=-1, bg_color=(0, 0, 0), image_alpha=1, kind='overlay'): | |||
background=DEFAULT, background_color=None, image_alpha=1, |
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.
If I understood correctly, this DEFAULT thing is introduced only to help in handling such complex deprecation scenarios. I think using it for other purposes would reduce user experience and should not be recommended.
Pehaps, changing the name to UPDATED
could better show its temporary nature.
@@ -75,7 +79,9 @@ def _match_label_with_color(label, colors, bg_label, bg_color): | |||
|
|||
|
|||
def label2rgb(label, image=None, colors=None, alpha=0.3, | |||
bg_label=-1, bg_color=(0, 0, 0), image_alpha=1, kind='overlay'): | |||
background=DEFAULT, background_color=None, image_alpha=1, | |||
kind='overlay', relabel=DEFAULT, |
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.
kind='overlay', relabel=DEFAULT, | |
kind='overlay', *, relabel=DEFAULT, |
@@ -0,0 +1,14 @@ | |||
class DefaultValue(object): |
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.
Good suggestion, 👍
label : array, shape (M, N) | ||
Integer array of labels with the same shape as `image`. | ||
image : array, shape (M, N, 3), optional | ||
label : array, shape (M, N,[[ P,] ...]) |
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.
label : array, shape (M, N,[[ P,] ...]) | |
label : array, shape (M, N,[ P[, ...]]) |
label : array, shape (M, N,[[ P,] ...]) | ||
Integer array of labels with the same shape as `image` (not including | ||
channels). | ||
image : array, shape (M, N,[[[ P,] ...,] 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.
image : array, shape (M, N,[[[ P,] ...,] 3]), optional | |
image : array, shape (M, N,[ P,[ ...,][ 3]), optional |
@soupault thanks for the blast from the past review! =) I'll try to pick this one up again soon. Yikes! LOL |
any updates on this? this is very useful! |
I don't know if this PR is still relevant (please see #4464). |
A subset of this was done elsewhere (the The proposed API change from: The other changes here are
If there is consensus that we should still work on these changes, I am happy to help update this PR along with another performance-based PR for |
I'm not a big fan of |
Description
I also updated parameter names and deprecated background=-1 as the default. I am currently stating that background=0 will be the default but I could also go for background=None.
This is the first PR with very verbose warning and error messages that we discussed in the mailing list. Comments very welcome.
Also included: a new utility DEFAULT value for use instead of None when deprecating. This makes it easy to distinguish between the use of the DEFAULT value because no value was passed, vs when the user explicitly passes None. I've kept it as simple as possible for now but this could be even more sophisticated, with a DEFAULT object actually holding a default value, rather than having to hardcode it somewhere inside the function. Comments also welcome here!
I still need to add tests for all the new code paths.
Checklist
[It's fine to submit PRs which are a work in progress! But before they are merged, all PRs should provide:]
./doc/examples
(new features only)References
Closes issue #2674
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.