gpt4 book ai didi

python - 如何将列表的值附加到 3D 数组 - python 和 opencv

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

由于我对 opencv 了解不多,所以这个问题可能很愚蠢。 不管怎样,我的问题是,我有一组 30 张图像,我正在计算所有 30 张图像的红色、绿色和蓝色 channel 的平均值,并将它们存储在 3 个不同的列表中,现在我想要的是附加这 3 个不同的列表值转换为 3D 数组:

[B_mean,
G_mean,
R_mean]

这是我的 BGR 平均值:

blue mean [25, 28, 66, 63, 59, 70, 64, 38, 33, 39, 22, 37, 48, 4, 13, 12, 6, 3, 22, 18, 23, 21, 22, 31, 38, 21, 34, 26, 21, 30]
green mean [27, 29, 68, 66, 63, 69, 66, 45, 48, 41, 38, 41, 41, 22, 21, 9, 7, 25, 35, 28, 37, 36, 35, 32, 36, 20, 27, 24, 18, 25]
read mean [25, 26, 70, 69, 71, 67, 66, 42, 45, 31, 40, 43, 37, 32, 33, 37, 30, 34, 34, 24, 28, 32, 30, 33, 36, 26, 24, 30, 24, 26]

比如 3 行 30 列。那我怎么才能得到这个呢?

谢谢!

最佳答案

只需使用numpy.array:

import numpy as np

red = range(0, 30)
blue = range(10, 40)
green = range(20, 50)
array = np.array([red, green, blue])
print array.shape
# (3, 30)

关于python - 如何将列表的值附加到 3D 数组 - python 和 opencv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21941428/

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