-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
make the low contrast check optional when saving images #3653
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
make the low contrast check optional when saving images #3653
Conversation
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.
It looks good. To get this PR as fast as possible, I suggest you don't try to change the default behaviour.
It may be desirable to change it, but as far as you are concerned for your batch scripts, it would be better for you to forgo that request in this particular PR.
If the PR gets approved quickly enough, it might even make it in 0.14.2 ;)
@christian-rauch I'm having the discussion here because github often closes the mini discussions that are around comments: Unfortunately, scikit-image has a deprecation cycle policy. Sometimes, often for warnings, it is broken, but often requires discussion. In this particular case, mostly because the release of 0.14.2 should be imminent (due to the fact that numpy 1.16 broke scikit-image), I suggest you keep the default behaviour change as a separate PR. It is therefore in your best interest to minimize the discussion as much as possible. |
Thanks for the comments and PR, @christian-rauch! And thanks for chiming in, @hmaarrfk! Good advice. =) I think either way this won't be in 0.14.2 though, @stefanv and I are working on getting this out the door today. (Though no promises because crap always goes wrong. LOL) Anyway, regarding low contrast, the problem is that before that message, we would always get people saying "I used scikit-image to save an image and it's all black when I open it in [Preview/Photoshop/Whatever]". All the time. That's what the warning is supposed to prevent, and actually my totally unscientific impression is that it's worked. So my intuition is that we should:
I am amenable to be convinced that I should just delete the damn thing altogether, but that'll take a bit more work. =) I do also think long term we want to offload all io to imageio, but that is also a hard sell. |
To increase the probability of being merged (and to make exporting less annoying) I reverted to the default behaviour. To prevent the check and warnings, |
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.
needs a small test.
@@ -203,6 +203,10 @@ def test_imsave_incorrect_dimension(): | |||
with testing.raises(ValueError): | |||
with expected_warnings([fname + ' is a low contrast image']): | |||
imsave(fname, np.zeros((2, 3, 2))) | |||
# test that low contrast check is ignored | |||
with testing.raises(ValueError): |
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.
why does this raise valueerror?
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 don't know. I just amended the part that is related to the low contrast warning exception.
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.
It just doesn't like the fact that there are 2 channels in the last dimension of the array.
Not an ideal test, but I'm ok with how this looks now.
Thanks!
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 looked into it a little further, there isn't currently a place to put these "tests for all plugins". So this is as good of a place as any. I don't think PIL is going away any time soon.
@jni, this is looking good. Minimally invasive 9 line PR, maybe good enough to get backported too ;) |
@scikit-image/core I think this PR is good to go if anybody has time to give it a second pass. |
Looks great to me, thanks for the contribution! |
🎉 |
Should this PR be accompanied by plans for deprecation? |
@stefanv imho it's a valuable check to have around. See my comment above regarding its original motivation. However I won't stand in the way if others prefer making "off" the default. |
Description
This PR makes the low constrast check optional when saving images.
As described in #2531 the low contrast check delays the image export and is generally only useful for natural images.
References
Fixe #2531
For reviewers
(Don't remove the checklist below.)
later.
__init__.py
.doc/release/release_dev.rst
.@meeseeksdev backport to v0.14.x