From 3ec643b1a0044226f195cf6de710dd9d24f4fee6 Mon Sep 17 00:00:00 2001 From: rep Date: Wed, 11 Nov 2015 13:29:49 +0100 Subject: [PATCH] add pixelisation effect --- hacheuur.py | 42 +- horizontal.simple.py | 8 - pixelate.py | 40 + test.pickle | 3547 +++++++++++++++++++++++++++++++++++++----- 4 files changed, 3247 insertions(+), 390 deletions(-) create mode 100644 pixelate.py diff --git a/hacheuur.py b/hacheuur.py index a2552f7..b6aad9c 100644 --- a/hacheuur.py +++ b/hacheuur.py @@ -21,6 +21,7 @@ import ImageEnhance #ouvertrure de l'image source et conversion en mode couleur 1bit im1 = Image.open(str(sys.argv[1])).convert('1') +#im1 = Image.open(str(sys.argv[1])).convert('L') im2 = im1.copy() #rapport d'allongement de la nouvelle image par rapport à la largeur de l'image originale @@ -33,7 +34,7 @@ Larg = im1.size[0] Haut = im1.size[1] import pickle -loadfile = True +loadfile = False class Sequence: def __init__(s): @@ -59,14 +60,14 @@ if loadfile: else : seq=Sequence() -for i in range(1): +for i in range(4): # constitution de la liste des tranches horizontales # genre comme si qu'on avait un 16 pistes :) # nombre aleatoire compris dans les limites de l'image def randHaut(): - return random.randint(0, im1.size[1]) + return random.randint(0, im1.size[1]/8)*8 if loadfile: randomCoupeHauteur = seq.randomCoupeHauteur @@ -99,12 +100,18 @@ for i in range(1): choix_rnd = seq.choix[i] randomCopyPosi = seq.randomCopyPosi[i] else: - proportions = [(160,6),(120,4),(120,8),(80,16),(60,16),(20,32),(8,24),(8,16),(5,64),(3,24),(2,24),(1,256),(1,128),(1,64),(1,32),(1,16),(1,8)] + ''' + 8 16 24 32 40 48 56 64 72 80 88 96 104 112 120 128 136 144 152 160 168 + ''' + #proportions = [(160,6),(120,4),(120,8),(80,16),(60,16),(20,32),(8,24),(8,16),(5,64),(3,24),(2,24),(1,256),(1,128),(1,64),(1,32),(1,16),(1,8)] + proportions = [(160,6),(120,4),(120,8),(80,16),(64,16),(24,32),(8,24),(8,16)] seq.proportions = proportions #proportions = seq.proportions[] choix_rnd = random.randint(0, len(proportions)-1) #choix_rnd = random.randint(0, len(proportions)-1) seq.choix.append(choix_rnd) + + largeur = proportions[choix_rnd][0] # positionnement de la copie, aleatoirement, entre 0 et la largeur totale de l'image @@ -130,17 +137,34 @@ for i in range(1): cx2 = randomCopyPosi + largeur # decoupage du sample im3 = im2.crop((cx1,haut,cx2,bas)) + print "im3 = im2.crop : "+str(im3.size) - draw = ImageDraw.Draw(im4) + draw = ImageDraw.Draw(im4) + loop = 0 + pixelSizeIndex = random.randint(0,20) + pixelSizeList = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,4,8] + pixelSize = pixelSizeList[pixelSizeIndex] + print " pixelSize = "+str(pixelSize) - #collage, n fois, du sample + + ''' COLLAGE DU SAMPLE + ''' while loop