【发布时间】:2019-12-29 14:18:11
【问题描述】:
我正在尝试了解 Python 中的图像处理。
所以,我将以下 31 x 31 像素的 JPG 图像存储在一个 numpy 数组中。
from PIL import Image
import numpy as np
sample = Image.open('datasets/1.jpg')
sample_arr = np.array(sample)
现在,
sample_arr.shape
返回
(31, 31, 3)
和
sample_arr[0].shape
返回
(31, 3)
据此,我了解到 sample_arr[0] 存储前 31 个像素值,sample_arr[1] 存储接下来的 31 个像素值,依此类推,直到 sample_arr[30] 存储最后 31 个像素值。所以我们存储在数组中的像素总数 = 31 x 31 = 961
我的问题是数组元素相对于我们看到的图像的顺序是什么? sample_arr[0] 是否存储图像最左上角向右方向的前 31 个像素?
【问题讨论】:
标签: python image numpy python-imaging-library