<分区>
我正在读取一个rgb图像如下
scipy.misc.imread()
我想通过从每个 channel 中选取一个元素(即 rgb 表示像素 0 和像素 1 等等)来展平一维数组。
谢谢
<分区>
我正在读取一个rgb图像如下
scipy.misc.imread()
我想通过从每个 channel 中选取一个元素(即 rgb 表示像素 0 和像素 1 等等)来展平一维数组。
谢谢
最佳答案
scipy.misc 中似乎没有read
.您是说 imread
吗?如果是这样,它将为您提供具有 flatten method 的 numpy 数组。
例子:
>>> from scipy.misc import imread
>>> img = imread("test.jpg")
0: array([[[135, 130, 136],
[139, 134, 140],
[132, 127, 133],
...
>>> img.flatten()
1: array([135, 130, 136, ..., 162, 160, 165], dtype=uint8)
关于python - 在 python 中展平 rgb 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15618815/