我知道如果在自己的子图中呈现图像,如何提取图像,如下所示:
Matplotlib figure to image as a numpy array
但是,我的代码略有不同,如下所示:
_, ax = plt.subplots(1, figsize=(20,20))
height, width = image.shape[:2]
ax.set_ylim(height + 10, -10)
ax.set_xlim(-10, width + 10)
ax.axis('off')
ax.set_title(title)
ax.text(x,y,"blabla")
#...some more things happen with ax here
some_image = 255*np.random.rand(20,20)
some_image = some_image.astype(np.uint8)
#Somethings happen with the image here
#....
ax.imshow(some_image.astype(np.uint8))
是否可以将显示的ax
对象作为一个numpy数组进行处理而不重写代码?