这就是你如何做到这一点,是的,分割是有帮助的,并使用我下面的相同数据类型
bitmap = np.zeros((10, 10, 3))
s_x = (1,2,3) ## tuple
s_y = (0,1,2) ## tuple
pixal_val = np.array([[0,0,1],[1,0,0],[0,1,0]]) ## np
bitmap[s_y, s_x] = pixal_val
plt.imshow(bitmap)
output:
Edit:
它确实可以使用 numpy 数组作为坐标,但请确保它们是 int 类型
bitmap = np.zeros((10, 10, 3))
s_x = np.array([a for a in range(10)], dtype=int)
s_y = np.array([a for a in range(10)], dtype=int)
np.random.shuffle(s_x)
np.random.shuffle(s_y)
pixel_val = np.random.rand(10,3)
bitmap[s_y, s_x] = pixel_val
plt.imshow(bitmap)
最终编辑:s_x ans s_y 我在上面修复了错误的方向