def image_neighbor_smooth(xlevel=<NUM_LIT>, ylevel=<NUM_LIT>, image="<STR_LIT>"):
if image == "<STR_LIT>": image = _pylab.gca().images[<NUM_LIT:0>]<EOL>Z = _n.array(image.get_array())<EOL>global image_undo_list<EOL>image_undo_list.append([image, Z])<EOL>if len(image_undo_list) > <NUM_LIT:10>: image_undo_list.pop(<NUM_LIT:0>)<EOL>dlevel = ((xlevel**<NUM_LIT:2>+ylevel**<NUM_LIT:2>)/<NUM_LIT>)**(<NUM_LIT:0.5>)<EOL>new_Z = [Z[<NUM_LIT:0>]*<NUM_LIT:1.0>]<EOL>for m in range(<NUM_LIT:1>,len(Z)-<NUM_LIT:1>):<EOL><INDENT>new_Z.append(Z[m]*<NUM_LIT:1.0>)<EOL>for n in range(<NUM_LIT:1>,len(Z[<NUM_LIT:0>])-<NUM_LIT:1>):<EOL><INDENT>new_Z[-<NUM_LIT:1>][n] = (Z[m,n] + xlevel*(Z[m+<NUM_LIT:1>,n]+Z[m-<NUM_LIT:1>,n]) + ylevel*(Z[m,n+<NUM_LIT:1>]+Z[m,n-<NUM_LIT:1>])+ dlevel*(Z[m+<NUM_LIT:1>,n+<NUM_LIT:1>]+Z[m-<NUM_LIT:1>,n+<NUM_LIT:1>]+Z[m+<NUM_LIT:1>,n-<NUM_LIT:1>]+Z[m-<NUM_LIT:1>,n-<NUM_LIT:1>])   )/ (<NUM_LIT:1.0>+xlevel*<NUM_LIT:2>+ylevel*<NUM_LIT:2> + dlevel*<NUM_LIT:4>)<EOL><DEDENT><DEDENT>new_Z.append(Z[-<NUM_LIT:1>]*<NUM_LIT:1.0>)<EOL>image.set_array(_n.array(new_Z))<EOL>_pylab.draw()<EOL>
This will bleed nearest neighbor pixels into each other with
the specified weight factors.