python - Coloring an edge detected image by user input co-ordinates..??What's wrong with this code? -


i need color white part surrounded black edges!

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<image_width , y<image_height , x>0 , y>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() 

255 detect white color, 150 used re-color greyish, , (100,100) starting pixel.

it's giving "max recursion depth" @ n=10114 , python crashes on n=10115 (the setrecursionlimit(n)).

what's while loop? never changes coordinates, seems loop forever, doing recursive calls. quick reading sounds should plain if.

also: drop parens while , if; they're not needed in python.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -