我有两个 numpy 数组:数据和掩码。掩码和数据大小不一样,所以我把它们想象成画布和邮票。如何在不同的位置印上我的画布?
import numpy as np
import matplotlib.pyplot as plt
# Make a canvas
canvas = np.zeros( 2500 ).reshape( 50, 50 )
# Make a "stamp"
r = 10
xx, yy = np.mgrid[ :r * 2, :r * 2 ]
stamp = ((xx - r) ** 2 + (yy - r) ** 2) < r**2
# Draw on the canvas
canvas[stamp] = 10
# Display the drawing
plt.imshow(canvas)
plt.show()
我明白了:
我怎样才能在不同的位置盖章才能得到这样的东西?