Closed
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: