gpt4 book ai didi

python - 为什么在使用 imshow 显示时使用 np.hstack 对图像进行零填充会使图像变白?

转载 作者:太空宇宙 更新时间:2023-11-03 22:07:31 24 4
gpt4 key购买 nike

<分区>

我有一个大小为 patch 的图像:(200, 350 , 3)

补丁:

enter image description here

我正在尝试使用以下方法水平堆叠黑色图像:

stacked_image = np.hstack((patch, np.zeros((200, 2450, 3))))

所以 stacked_image 的形状是:(200, 2800, 3)

但是当我用 plt.imshow()cv2.imshow() 显示它时,图像 block 变白了 enter image description here

我不明白为什么补丁会变白。我期待补丁图像和其余列像素为黑色。我怎样才能做到这一点?

此外,当我使用 cv2.imwrite 保存图像时,我得到了预期的输出:

cv2.imwrite(r'hstack.png', np.hstack((patch, np.zeros((200, 2450, 3)))))

enter image description here

谁能解释为什么会这样?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com