Coloring an edge detected image by user input co-ordinates..??What's wrong with this code?
<p>I need to color the white part surrounded by black edges!</p>

<pre><code>from PIL import Image
import sys
image=Image.open("G:/ghgh.bmp")
data=image.load()

image_width,image_height=image.size   

sys.setrecursionlimit(10115)

def f(x,y):
    if(x&lt;image_width and y&lt;image_height and x&gt;0 and y&gt;0):
        if (data[x,y]==255):
            image.putpixel((x,y),150) 
            f(x+1,y)
            f(x-1,y)
            f(x,y+1)
            f(x,y-1)
            f(x+1,y+1)
            f(x-1,y-1)
            f(x+1,y-1)
            f(x-1,y+1)
f(100,100)
image.show()
</code></pre>

<p>255 is to detect white color, 150 is used to re-color greyish, and (100,100) is the starting pixel.</p>

<p>It's giving "Max recursion depth" at n=10114 and python crashes on n=10115 (the <code>setrecursionlimit(n)</code>).</p>
