Iterating over an image in python
<p>I would like to iterate over an image in python. 
This is my code so far:</p>

<pre><code>def imageIteration(greyValueImage):
    for (x,y), pixel in np.ndenumerate(greyValueImage):
        vals = greyValueImage[x, y]
        print(vals)
</code></pre>

<p>The problem here ist that I get the following exception:</p>

<pre><code>for (x,y), pixel in np.ndenumerate(greyValueImage):
ValueError: too many values to unpack
</code></pre>

<p>Now my question is what is the fastest way to solve this?
Do I really need to split the image into a few peaces, but taking this step how do I get the count of the necessary loops without trying out?</p>

<p>Thanks for Your ideas </p>

<p>P.s.
im = Image.open(args["image"])
im_grey = im.convert('LA') # convert to grayscale</p>

<p>What is the value of greyValueImage?</p>

<p>There should be nothing wrong with your code, you can of course unpack the values of a tuple in a for loop.</p>

python image loops for-loop iteration