【发布时间】:2017-07-07 13:47:27
【问题描述】:
我加载一个图像并将其添加到一个空的 numpy 数组中:
plt.imshow(im)
plt.show()
im = imread('/path_to_image',mode = 'RGB')
array = np.zeros((1, 299, 299,3), dtype = np.int8)
array[0][:,:,:3] = im
print(array[0].shape)
print(im.shape)
plt.imshow(array[0])
plt.show()
我希望这两个图像在显示时看起来相同。当我将它分配给一个数组时,图像似乎发生了变化:
array = np.zeros((1, 299, 299,3), dtype = np.int8)
array[0][:,:,:3] = im
【问题讨论】:
-
你不应该使用
np.uint8:array = np.zeros((1, 299, 299,3), dtype = np.uint8)吗? -
你是对的,使用 uint 有帮助!