def permutation_blocs(img : Image, zone=None): '''entrée : une image chargée avec le module PIL la zone de l'image à traiter sortie : aucune, la permutation des quadrants est effectuée "sur place" ''' if zone is None : zone=(0,0,img.width,img.height) g,h,d,b = zone k = (d-g)//2 assert (b-h)//2 == k for x in range(g,g+k): for y in range(h,h+k): tmp = img.getpixel( (x,y) ) img.putpixel( (x,y), img.getpixel( (x,y+k) ) ) img.putpixel( (x,y+k), img.getpixel( (x+k,y+k) ) ) img.putpixel( (x+k,y+k), img.getpixel( (x+k,y) ) ) img.putpixel( (x+k,y), tmp )