python - 为什么我在 RGB 中得到负数?
问题描述
我想让我的照片分成 rgb 值。当我制作 3d 绘图时显示有负 RGB 值,尽管它应该是 0 值而不是负值。为什么会发生?有什么解决办法吗?
这是代码
这是 3dplot 负 rgb 值
这是代码
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import cv2
#read image
img = cv2.imread('warna.jpg')
#convert from BGR to RGB
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
#get rgb values from image to 1D array
r, g, b = cv2.split(img)
print r
print g
print b
r = r.flatten()
g = g.flatten()
b = b.flatten()
#plotting
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter(r, g, b)
plt.show()
解决方案
我怀疑这些值实际上是0
负数而不是负数,它在情节中看起来就是这样。你可以打印min
ofr
g
和b
吗?
推荐阅读
- ruby-on-rails - 设计的 require_no_authentication 操作中的 AbstractController::DoubleRenderError
- .net - dotnet watch 在升级到 .NET 6 后忽略端口号 launchsettings.json
- ruby-on-rails - Ruby on Rails:同时处理域和子域级别的 cookie
- c++ - 尝试删除初始化列表构造函数并不总是生效
- python - Python 正则表达式匹配包含两个或更少 o 字符的空格分隔的单词
- python - 从 Sci-Keras 而不是 Keras 导入 KerasRegresor 会改变我的 cross_val_score 的结果。我如何解释新数字?
- python - 如何将决策树中的阈值与其节点匹配?
- python - 替换列表中特定索引处的值
- flutter - 发布应用后蓝牙扫描无法正常工作
- azure-data-factory - 我可以在本地创建参数吗?