我有一个存储为ndarray
. 我想遍历这个数组中的每个像素。
我可以像这样遍历数组的每个元素:
from scipy import ndimage
import numpy as np
l = ndimage.imread('sample.gif', mode="RGB")
for x in np.nditer(l):
print x
这给出了即:
...
153
253
153
222
253
111
...
这些是像素中每种颜色的值,一个接一个。我想要的是 3 到 3 读取这些值以产生如下内容:
...
(153, 253, 153)
(222, 253, 111)
...