gpt4 book ai didi

python - Opencv 转换为灰度无法正常工作

转载 作者:太空宇宙 更新时间:2023-11-03 12:37:20 25 4
gpt4 key购买 nike

<分区>

我一直在尝试使用 Python 中的 opencv 将图像转换为灰度,但它会将图像转换为某种热像仪图像。我究竟做错了什么?这是下图的代码:

img =X_tr[9999]
plt.imshow(img)
plt.show()
img = cv2.cvtColor(img.astype(np.uint8), cv2.COLOR_RGB2GRAY)
plt.imshow(img)
plt.show()
img.shape

这张图片取自 CIFAR10 数据集。谢谢。 Code and result after using opencv

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