I have a .png image with alpha and a random template generated using numpy. I want to secure both images using matplotlib. The bottom image should be a random pattern, and above that I want to see the second image (attached at the end of the message).
The code for both images is as follows:
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
fig = plt.subplots(figsize = (20,4))
x = np.arange(0,2000,1)
y = np.arange(0,284,1)
X,Y = np.meshgrid(x,y)
Z = 0.6+0.1*np.random.rand(284,2000)
Z[0,0] = 0
Z[1,1] = 1
plt.pcolormesh(X,Y,Z,cmap = cm.gray)
The result is the following image:

To import the image, I use the following code:
fig = plt.subplots(figsize = (20,4))
plt.imread("good_image_2.png")
plt.imshow(img)
print(img.shape)
The image is as follows:

So the final result I want is:

source
share