for in xy image if image getpixel black pixel new_fragment set for dot

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
for x, y in xy(image):
if image.getpixel((x,y)) == 0: # black pixel
new_fragment = set([(x, y)])
for dot in (
(x-1, y-1), (x+0, y-1), (x+1, y-1),
(x-1, y+0),):# (x+1, y+0),
if frags.has_key(dot):
new_fragment.update(frags[dot][0])
frags[dot][0] = new_fragment
frags[(x,y)] = [new_fragment]