Skip to content

imshow alpha interpolation looks wrong #11316

@fargiolas

Description

@fargiolas

Hi, not much of an issue, but it seems that imshow is not interpolating RGBA images in the proper way. There was some discussion about a similar issue in #9906 which ended up on a documentation note:

imshow expects RGB images adopting the straight (unassociated) alpha representation.

If that's the case imshow should still switch to associated colors (premultiply alpha) before interpolation to avoid artefacts like the one below, shouldn't it?

import matplotlib.pyplot as plt
import numpy as np

fig, (axl, axr) = plt.subplots(1, 2)

# full green image
img = np.zeros((5, 5, 4))
img[...,1] = np.ones((5, 5))
# transparent above main diagonal
img[...,3] = np.tril(np.ones((5, 5), dtype=np.uint8))

axl.imshow(img, interpolation="none")
axr.imshow(img, interpolation="bilinear")

plt.show()

bug

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions