python - 在 python 中展平 rgb 图像

标签 python image

<分区>

我正在读取一个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/

相关文章:

python - Django 管理员 : removing app name from URL for single-app projects

python标准输入eof

android - android 中的 IllegalArgumentException : x + width must be <= bitmap. width()

html - 根据屏幕分辨率裁剪图像的右侧

python - 使用 numpy 的 python 中的多线性映射

python - 如何在Python中使用or运算符

python - xlabel、ylabel 不工作。 'str' 对象不可调用

python - Django-Oscar 图像错误

python - 如何为按时间排序的 matplotlib 图序列制作动画

html - 图像不显示内联