jeudi 28 juillet 2016

PIL - apply the same operation to every pixel

I create an image and fill the pixels:

img = Image.new( 'RGB', (2000,2000), "black") # create a new black image
pixels = img.load() # create the pixel map

for i in range(img.size[0]):    # for every pixel:
    for j in range(img.size[1]):
      #do some stuff that requires i and j as parameter

Can this be done more elegant (and may be faster, since theoretically the loops are parallelizable)?

Aucun commentaire:

Enregistrer un commentaire