FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Issues with `imshow` and RGBA values · Issue #3343 · matplotlib/matplotlib · GitHub

Repository navigation

Issues with imshow and RGBA values #3343

Description

Raised at https://stackoverflow.com/questions/25089068/how-does-imshow-handle-the-alpha-channel-with-an-m-x-n-x-4-input by @mwaskom

import numpy as np
import matplotlib.pyplot as plt

d = np.ones((100, 100, 4), dtype=np.uint8)*255
d[:, :, 3] = np.linspace(0, 255, num=100)
plt.imshow(d, interpolation='none')
plt.show()

One might expect the image to be completely white (as semi-transparent white over white should still be white), but is instead gray in the middle due to pre-multiplying of the alpha (1, 1, 1, .5) -> (.5, .5, .5) which is then composited with the background as an opaque layer, hence the gray.

Previously (related) discussion:

Activity

  1. added this to the milestone on Aug 4, 2014
  2. gcr commented on Mar 13, 2015

    This issue also affects me. Looks like matplotlib is doing some double-multiplication of the alpha value.

    Matplotlib's current incorrect behavior is also confusing existing users on stackoverflow, which is in fact how I found this issue: http://stackoverflow.com/questions/25089068/how-does-imshow-handle-the-alpha-channel-with-an-m-x-n-x-4-input

  3. modified the milestones: , on Mar 13, 2015
  4. modified the milestones: , on Jul 17, 2015
  5. hitzg commented on Sep 29, 2015

  6. goerz commented on Oct 11, 2015

    I'm also running into this. Here's an interactive notebook that should illustrate the issue nicely: http://nbviewer.ipython.org/gist/goerz/d6543e0878c1a10ed0da

  7. QuLogic commented on Sep 30, 2016

    Member

    @tacaswell This was fixed by #5718 and the one I meant to close instead of #5949.

  8. modified the milestones: , on Sep 30, 2016
  9. tacaswell commented on Oct 3, 2016

    MemberAuthor

    @QuLogic Ah, that makes more sense.

    Thanks for all of your work keeping the issues tidy!

  10. thomasmansencal commented on Nov 28, 2017

    Contributor

    I that issue fixed? I'm running 2.1.0 and I still see the same issue:

    What I get using imshow:

    What I would expect (composited in The Foundry Nuke):

    Original image is here: https://drive.google.com/file/d/1S09dwNcsO5sWvfBB2mMs29O0ZSAcM1pk/view?usp=sharing

  11. tacaswell commented on Dec 1, 2017

    MemberAuthor

    @kelsolaar Can you open a new issue for this with a minimal example?

  12. thomasmansencal commented on Dec 1, 2017

    Contributor

    @tacaswell : I will!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL