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

Appearance settings

Issues with imshow and RGBA values #3343

Copy link
Copy link
Closed
@tacaswell

Description

@tacaswell
Issue body actions

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:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.