【发布时间】:2015-03-26 08:07:45
【问题描述】:
我有一个存储为ndarray 的图像。我想遍历这个数组中的每个像素。
我可以像这样遍历数组的每个元素:
from scipy import ndimage
import numpy as np
l = ndimage.imread('sample.gif', mode="RGB")
for x in np.nditer(l):
print x
这给出了 ie:
...
153
253
153
222
253
111
...
这些是像素中每种颜色的值,一个接一个。相反,我想要的是读取这些值 3 到 3 以产生如下内容:
...
(153, 253, 153)
(222, 253, 111)
...
【问题讨论】:
标签: python numpy scipy multidimensional-array ndimage