我有一张图像,它被存储为一个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个一组的方式生成类似于以下内容的内容:
...
(153, 253, 153)
(222, 253, 111)
...