detect a single ball out of two (Python)
<p>So i've got an image in input an i transformed it into an array. There is two ball, and i want to remove one ball.
My idea is to run through a loop, and detect line by line if there is a red pixel. And if in this array at an i, and there is not red pixel in i+1 it erase the entire rest of the line.</p>

<pre><code>for i in range(0, len(data)):
    h = h + 1
    #print("0"),
    if (i&gt;1) and (((data[i - 1])[1] &gt; 40  and (data[i - 1])[2] &gt; 40 ) and ((data[i + 1])[1] &gt; 40 and (data[i+1])[2])):
           print("_"),
    elif  (data[i])[1] &lt; 40 and (data[i])[2] &lt; 40 and (data[i])[0] &gt; 50  :
               j = j + 1
               print "#" ,
    else :
                   print("."),
               #else : 
       # print data[i],


    if h == 64 :
       h = 0
       test = True

       print("\n") 
</code></pre>

<p>What is wrong with my code and how can i erase a ball through my method ?</p>
