&quot“ pcolormesh”给我奇怪的结果

发布于 2025-02-07 20:20:01 字数 1022 浏览 0 评论 0原文

我想使用PCOLORMESH绘制RGB图像。但是,我只能单独添加红色,绿色的蓝色通道,但我只会得到缩放图像。

我缺少选项吗?看起来PcoLormesh将像素值正常化

----更新 -

当我在下面再次重建代码时,它会像绿色的怪物一样向上倒下。

import matplotlib.pyplot as plt
import numpy as np
import cv2
from tensorflow.keras.datasets import cifar10

(x_train, y_train), (x_test, y_test) = cifar10.load_data()
 
x_test = x_test.reshape(10000, 32, 32, 3)
x_test = x_test.astype('float32')
x = x_test[i, :]
x = x.reshape(32,32,3)

blue,green,red = cv2.split(x)

print(blue)

plt.figure(figsize=(3,3))
plt.pcolormesh(red)
plt.pcolormesh(green)
plt.pcolormesh(blue)
plt.show()
  

我期望这个

,但这只给了我这个

I would like to plot RGB image using pcolormesh. But I only get scaled image although I added Red, Green Blue channels individually.

Am I missing option or something? It looks like pcolormesh normalize the pixel values

---Update--

When I rebuild my code again below, it gives me color like a green monster flipped up-side-down.

import matplotlib.pyplot as plt
import numpy as np
import cv2
from tensorflow.keras.datasets import cifar10

(x_train, y_train), (x_test, y_test) = cifar10.load_data()
 
x_test = x_test.reshape(10000, 32, 32, 3)
x_test = x_test.astype('float32')
x = x_test[i, :]
x = x.reshape(32,32,3)

blue,green,red = cv2.split(x)

print(blue)

plt.figure(figsize=(3,3))
plt.pcolormesh(red)
plt.pcolormesh(green)
plt.pcolormesh(blue)
plt.show()
  

I expect this
enter image description here

But it only gives me this
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文