I have an image that is stored as an ndarray
. I would like to iterate over each pixel in this array.
I can iterate over each element of the array like this:
from scipy import ndimage
import numpy as np
l = ndimage.imread('sample.gif', mode="RGB")
for x in np.nditer(l):
print x
This gives ie:
...
153
253
153
222
253
111
...
These are the values of each color in the pixels, one after the other. What I would like instead is to read these values 3 by 3 to produce something like this:
...
(153, 253, 153)
(222, 253, 111)
...