Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed

Conversation

tillahoffmann
Copy link
Contributor

@tillahoffmanntillahoffmann commentedMar 2, 2017
edited
Loading

This PR allows thealpha argument ofimshow to be an array with shape matching the image to support pixel-by-pixel opacity.

@dstansby
Copy link
Member

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.

@dstansbydstansby added this to the2.1 (next point release) milestoneMar 2, 2017
@@ -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)
Copy link
Member

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

Copy link
ContributorAuthor

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.

rotate_image-failed-diff

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.

screen shot 2017-03-03 at 15 03 01
screen shot 2017-03-03 at 15 03 06

Copy link
ContributorAuthor

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.

@tacaswell
Copy link
Member

I have to run to dinner, but I suspect the==0 change is what is breaking the tests, which should be pulled out into it's own PR and put (with re-rendering the tests) on 2.0.x.

@QuLogic
Copy link
Member

Please rebase instead of merging, and don't make extra empty commits just to trigger CI.

@dstansby
Copy link
Member

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.

@tillahoffmann
Copy link
ContributorAuthor

Ok, will do that in the future.

@tacaswelltacaswell self-assigned thisMar 8, 2017
@tacaswell
Copy link
Member

Please leave this one for me to review / merge.

@tacaswelltacaswell modified the milestones:2.1 (next point release),2.2 (next next feature release)Aug 29, 2017
@jklymak
Copy link
Member

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
Copy link
ContributorAuthor

tillahoffmann commentedJul 25, 2019
edited
Loading

Will close this one and send a new PR because the implementation has changed enough to make a new implementation easier.

jklymak reacted with thumbs up emoji

@jklymak
Copy link
Member

Don’t be shy at harassing us

@tacaswell
Copy link
Member

🐑 I thought this had gone in already! This one is definitely on me...

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell left review comments

Assignees

@tacaswelltacaswell

Projects
None yet
Milestone
v3.2.0
Development

Successfully merging this pull request may close these issues.

5 participants
@tillahoffmann@dstansby@tacaswell@QuLogic@jklymak

[8]ページ先頭

©2009-2025 Movatter.jp