
from PIL.Image import *

def mystere(i):
    (l, h) = i.size
    for y in range(h):
        for x in range(l):
            c = Image.getpixel(i, (x, y))
            inv = 255 - c
            Image.putpixel(i, (x, y), inv)

i=open("nb.png")
Image.show(i)

mystere(i)
Image.show(i)
