Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Thanks for submitting this, it looks like a good improvement! A couple of things that need to be fixed:
There's lots of information that should cover the above athttp://matplotlib.org/devel/index.html - let us know if you need any help with anything though. |
@@ -419,14 +428,18 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, | |||
# colormapping works correctly | |||
hid_output = output | |||
output = np.ma.masked_array( | |||
hid_output[..., 0], hid_output[..., 3]< 0.5) | |||
hid_output[..., 0], hid_output[..., 3]== 0) |
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.
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 arebad 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.
I have to run to dinner, but I suspect the |
Please rebase instead of merging, and don't make extra empty commits just to trigger CI. |
FYI, we (members of the matplotlib organisation) can manually trigger CI if needed, and you should be able to manually trigger it on your own fork. |
Ok, will do that in the future. |
Please leave this one for me to review / merge. |
This looks useful, but fell under the radar.@tillahoffmann do you have the bandwidth to rebase, and we can try and resurrect? If no one touches it for a while, please ping (and re-ping). Sorry for the lack of response here. |
tillahoffmann commentedJul 25, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Will close this one and send a new PR because the implementation has changed enough to make a new implementation easier. |
Don’t be shy at harassing us |
🐑 I thought this had gone in already! This one is definitely on me... |
Uh oh!
There was an error while loading.Please reload this page.
This PR allows the
alpha
argument ofimshow
to be an array with shape matching the image to support pixel-by-pixel opacity.