-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Allow array alpha for imshow #8183
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
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
157fc86
Allow array alpha for imshow.
tillahoffmann 8916fa9
Remove unnecessary logic branch.
tillahoffmann fd0ed02
Fix PEP8.
tillahoffmann c9c96ab
Only restore alpha channel if `_array_alpha` is given.
tillahoffmann f04266b
Merge remote-tracking branch 'upstream/master' into arrayalpha
tillahoffmann f6e788a
Rerender test images.
tillahoffmann efc8b74
Add test for array alpha.
tillahoffmann b9bce13
Update docstring.
tillahoffmann c5437e5
Merge remote-tracking branch 'upstream/master' into arrayalpha
tillahoffmann fdbc951
Trigger CI
tillahoffmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+67.4 KB
lib/matplotlib/tests/baseline_images/test_image/image_array_alpha.pdf
Binary file not shown.
Binary file added
BIN
+99.1 KB
lib/matplotlib/tests/baseline_images/test_image/image_array_alpha.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
385 changes: 385 additions & 0 deletions
385
lib/matplotlib/tests/baseline_images/test_image/image_array_alpha.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+871 Bytes
(100%)
lib/matplotlib/tests/baseline_images/test_image/mask_image_over_under.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+272 Bytes
(100%)
lib/matplotlib/tests/baseline_images/test_image/rotate_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is going to break a test, but may fix an issue that @QuLogic found with imshow after #8024
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.
Yes, this line is indeed causing the problem. In particular, the alpha channel is interpolated near the boundary of an image. The
< 0.5
implementation will set pixels that are "more than half transparent" to fully transparent whereas the== 0
implementation only treats them as masked if they are fully transparent.In short, the boundaries in a few tests differ slightly.
I believe the
== 0
implementation is preferable because it effectively provides anti aliasing on the boundary by restoring the alpha channel. Here is a zoomed-in example.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.
Hm, but this causes trouble if there are bad data in image. For example, bad values in one of the tests are shown as blue. If we restore the alpha channel, all bad blue values will become transparent. As a compromise, I have rerendered the problematic images (changes only occur at the boundary) and I only restore the alpha channel if
_array_alpha
is given.