Version bataille navale

This commit is contained in:
rep 2015-11-27 17:48:35 +01:00
parent a60bd13677
commit b13dace596
6 changed files with 12227 additions and 434 deletions

12
.gitignore vendored
View File

@ -1,2 +1,10 @@
pylone3 captain/
test drone/
pln/
pylone3/
screen/
test/
tth/
drone.mp4
drone.2.mp4
test.jpg2015-09-29-21h22m05s.jpg

View File

@ -6,6 +6,14 @@
# image source : pln.jpg # image source : pln.jpg
# image obtenue : pln..20150910-11h59m53s.jpg # image obtenue : pln..20150910-11h59m53s.jpg
# pln.png 3936x1024 pix
'''
image input puredata : 16384 width x 768 height
donc par exemple, pour 3 images :
3 x 16384 = 49152 pixels en tout
'''
import sys import sys
import Image import Image
import random import random
@ -16,24 +24,31 @@ import ImageFilter
from time import gmtime, strftime from time import gmtime, strftime
import time import time
if not len(sys.argv) > 1:
raise SystemExit("Usage: %s image_source" % sys.argv[0])
# modifs du 30/10/2013 # modifs du 30/10/2013
import ImageEnhance import ImageEnhance
#ouvertrure de l'image source et conversion en mode couleur 1bit #ouverture 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('1')
#im1 = Image.open(str(sys.argv[1])).convert('L')
#im1 = Image.open(str(sys.argv[1]))
im2 = im1.copy() im2 = im1.copy()
#rapport d'allongement de la nouvelle image par rapport à la largeur de l'image originale #rapport d'allongement de la nouvelle image par rapport à la largeur de l'image originale
allongement = 4 allongement = 8
im3 = Image.new("RGBA",(im1.size[0], im1.size[1])) im3 = Image.new("RGBA",(im1.size[0], im1.size[1]))
im4 = Image.new("RGBA",(im1.size[0]*allongement, im1.size[1])) im4 = Image.new("RGBA",(im1.size[0]*allongement, im1.size[1]))
#im4 = Image.new("RGBA",(49152, im1.size[1]))
Larg = im1.size[0] Larg = im1.size[0]
Haut = im1.size[1] Haut = im1.size[1]
import pickle import pickle
loadfile = True loadfile = False
class Sequence: class Sequence:
def __init__(s): def __init__(s):
@ -53,6 +68,7 @@ seq["choix"] = []
seq["sizeOutput"]= im4.size seq["sizeOutput"]= im4.size
seq["sizeInput"] = im1.size seq["sizeInput"] = im1.size
""" """
if loadfile: if loadfile:
seq=pickle.load(open("test.pickle")) seq=pickle.load(open("test.pickle"))
@ -61,12 +77,11 @@ else :
for i in range(1): for i in range(1):
# constitution de la liste des tranches horizontales # constitution de la liste des tranches horizontales
# genre comme si qu'on avait un 16 pistes :) # genre comme si qu'on avait un 16 pistes :)
# nombre aleatoire compris dans les limites de l'image # nombre aleatoire compris dans les limites de l'image
def randHaut(): def randHaut():
return random.randint(0, im1.size[1]) return random.randint(0, im1.size[1]/8)*8
if loadfile: if loadfile:
randomCoupeHauteur = seq.randomCoupeHauteur randomCoupeHauteur = seq.randomCoupeHauteur
@ -93,19 +108,43 @@ for i in range(1):
i=0 i=0
#!!!!!!!!!! #!!!!!!!!!!
while n<im4.size[0] : while n<im4.size[0] :
if loadfile: if loadfile:
proportions = seq.proportions proportions = seq.proportions
choix_rnd = seq.choix[i] choix_rnd = seq.choix[i]
randomCopyPosi = seq.randomCopyPosi[i] randomCopyPosi = seq.randomCopyPosi[i]
else: 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),(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 = [(1280,1),(800,1),(800,2),(640,1),(640,2),(640,4),(320,4),(320,2),(320,1),(160,1),(120,2),(120,3),(80,6),(64,12),(64,6),(32,4),(32,8),(32,16),(32,32),(32,64)]
proportions = [(256,1),(160,1),(120,2),(120,3),(80,6),(64,12),(24,18),(8,24),(8,16)]
#proportion pln pour output final avec puredata/gem (decalage phase 32pix)
'''
proportions = [ (768,2),\
(512,4),\
(256,8),\
(128,4),(128,16),\
(64,4),(64,8),(64,16),\
(32,8),(32,16),(32,32),(32,32),(32,64),(32,128),\
(16,1),(16,4),(16,16),(16,64)]
'''
#proportions = [(512,1),(256,2),(128,4),(64,8),(64,4),(32,16),(32,32),(32,8),(16,8),(16,32),(8,64),(8,32),(8,16)]
#proportions = [(32,1),(32,2),(32,3),(32,4),(32,5),(32,6),(32,8),(32,12),(32,16),(32,24),(32,32),(32,64)]
seq.proportions = proportions seq.proportions = proportions
#proportions = seq.proportions[] #proportions = seq.proportions[]
choix_rnd = random.randint(0, len(proportions)-1) choix_rnd = random.randint(0, len(proportions)-1)
#choix_rnd = random.randint(0, len(proportions)-1) #choix_rnd = random.randint(0, len(proportions)-1)
seq.choix.append(choix_rnd) seq.choix.append(choix_rnd)
largeur = proportions[choix_rnd][0]
# positionnement de la copie, aleatoirement, entre 0 et la largeur totale de l'image # positionnement de la copie, aleatoirement, entre 0 et la largeur totale de l'image
randomCopyPosi = random.randint(0, (im1.size[0]-largeur)) randomCopyPosi = random.randint(0, (im1.size[0]-largeur))
@ -116,14 +155,12 @@ for i in range(1):
# tirage au sort # tirage au sort
#seq["choix"].append(choix_rnd) #seq["choix"].append(choix_rnd)
# assignation des valeurs (paires) finales choisies # assignation des valeurs (paires) finales choisies
largeur = proportions[choix_rnd][0] largeur = proportions[choix_rnd][0]
repeat = proportions[choix_rnd][1] repeat = proportions[choix_rnd][1]
#seq["randomCopyPosi"].append(randomCopyPosi) #seq["randomCopyPosi"].append(randomCopyPosi)
cx1 = randomCopyPosi cx1 = randomCopyPosi
@ -131,16 +168,39 @@ for i in range(1):
# decoupage du sample # decoupage du sample
im3 = im2.crop((cx1,haut,cx2,bas)) im3 = im2.crop((cx1,haut,cx2,bas))
print "im3 = im2.crop : "+str(im3.size)
draw = ImageDraw.Draw(im4) draw = ImageDraw.Draw(im4)
loop = 0 loop = 0
#collage, n fois, du sample pixelSizeList = [1,1,1,1,1,1,1,1,4,8]
#pixelSizeList = [1]
pixelSizeIndex = random.randint(0,len(pixelSizeList)-1)
pixelSize = pixelSizeList[pixelSizeIndex]
'''
print " pixelSize = "+str(pixelSize)
'''
''' COLLAGE DU SAMPLE
'''
while loop<repeat: while loop<repeat:
px1 = n px1 = n
px2 = n + largeur px2 = n + largeur
draw = ImageDraw.Draw(im3) draw = ImageDraw.Draw(im3)
''' PIXELISATION
'''
im3 = im3.resize((im3.size[0]/pixelSize, im3.size[1]/pixelSize), Image.NEAREST)
im3 = im3.resize((im3.size[0]*pixelSize, im3.size[1]*pixelSize), Image.NEAREST)
'''
print "im3.size="+str(im3.size)
print "im4.size="+str(im4.size)
'''
#lignes colorées de 1 pix #lignes colorées de 1 pix
draw.line((im3.size[0]-1, 0, im3.size[0]-1, im3.size[1]-1), fill="rgb(255,255,255)") draw.line((im3.size[0]-1, 0, im3.size[0]-1, im3.size[1]-1), fill="rgb(255,255,255)")
@ -149,6 +209,8 @@ for i in range(1):
n = n + largeur n = n + largeur
loop = loop + 1 loop = loop + 1
''' OPTIONS
'''
def TrancheHorizontale() : def TrancheHorizontale() :
# tirage au hasard de la bande copiee # tirage au hasard de la bande copiee
pos = random.randint(0, im1.size[1]-im1.size[1]/20) pos = random.randint(0, im1.size[1]-im1.size[1]/20)
@ -167,6 +229,9 @@ for i in range(1):
for j in range(len(randomCoupeHauteur)-1): for j in range(len(randomCoupeHauteur)-1):
Hacheur(randomCoupeHauteur[j], randomCoupeHauteur[j+1]) Hacheur(randomCoupeHauteur[j], randomCoupeHauteur[j+1])
''' SAUVEGARDE
'''
# CTRL + S # CTRL + S
#chemin du script : scriptpy = sys.argv[0] #chemin du script : scriptpy = sys.argv[0]
#chemin de l'image : str(sys.argv[1]) #chemin de l'image : str(sys.argv[1])
@ -180,3 +245,26 @@ for i in range(1):
#millis = int(round(time.time() * 1000)) #millis = int(round(time.time() * 1000))
#print "millis-secondes : "+str(millis) #print "millis-secondes : "+str(millis)
#obtenir les valeurs RGB des pixels de l'image
'''
from PIL import Image
im = Image.open('test.png')
pixels = list(im.getdata())
width, height = im.size
pixels = [pixels[i * width:(i + 1) * width] for i in xrange(height)]
for r in range(0, height-1) :
print "pixels = "+str(pixels[r])
print " "
print "len(pixels) = "+str(len(pixels))
print "width = "+str(width)
print "height = "+str(height)
print " "
#tintin = im.tostring( "raw", "RGBA", 0, -1)
#print "tostring = "+tintin
'''

View File

@ -4,7 +4,6 @@ from time import gmtime, strftime
fichier=sys.argv[1] fichier=sys.argv[1]
try: try:
im1 = Image.open(fichier).convert('1') im1 = Image.open(fichier).convert('1')
im2 = im1.copy() im2 = im1.copy()
@ -28,7 +27,6 @@ while x < im1.size[0] :
# ALPHA tout bete : # ALPHA tout bete :
im3 = Image.blend(im1, im2, 0.8) im3 = Image.blend(im1, im2, 0.8)
n = "%05d" % x n = "%05d" % x
nomdefichier = "horizontal"+n+".png" nomdefichier = "horizontal"+n+".png"
im3.save(nomdefichier, "PNG") im3.save(nomdefichier, "PNG")
@ -43,9 +41,3 @@ print " OUTPUT FINAL : "+fichier+".final.mp4"
# Nettoyage # Nettoyage
os.system("rm horizontal*.png") os.system("rm horizontal*.png")

40
pixelate.py Normal file
View File

@ -0,0 +1,40 @@
from PIL import Image
'''
backgroundColor = (0,)*3
'''
pixelSize = 8
image = Image.open('pixelate_input.png')
image = image.resize((image.size[0]/pixelSize, image.size[1]/pixelSize), Image.NEAREST)
image = image.resize((image.size[0]*pixelSize, image.size[1]*pixelSize), Image.NEAREST)
pixel = image.load()
'''
for i in range(0,image.size[0],pixelSize):
for j in range(0,image.size[1],pixelSize):
for r in range(pixelSize):
pixel[i+r,j] = backgroundColor
pixel[i,j+r] = backgroundColor
'''
image.save('pixelate_output.png')
'''
load
im.load()
Allocates storage for the image and loads it from the file (or from the source, for lazy operations). In normal cases, you dont need to call this method, since the Image class automatically loads an opened image when it is accessed for the first time.
(New in 1.1.6) In 1.1.6 and later, load returns a pixel access object that can be used to read and modify pixels. The access object behaves like a 2-dimensional array, so you can do:
pix = im.load()
print pix[x, y]
pix[x, y] = value
Access via this object is a lot faster than getpixel and putpixel.
'''

12356
test.pickle

File diff suppressed because it is too large Load Diff

111
video2d.py Normal file
View File

@ -0,0 +1,111 @@
#!/usr/bin/python
# coding: utf-8
'''
ffmpeg -i drone.mp4 -vf fps=30 ./drone/img%03d.jpg
'''
import sys # sys.argv[]
import Image # Image.open()
import os # os.getcwd
'''
im1 = Image.open(str(sys.argv[1]))
width, height = im1.size
print "width =% 5.2i" % width
print "height =% 5.2i" % height
allongement = 8
im4 = Image.new("RGBA",(im1.size[0]*allongement, im1.size[1]))
for x in range(1,allongement+1):
print('%03.1i' % x)
'''
script = os.getcwd()
print script
index = 1
allongement = 10 #4818
im1 = Image.open("./captain/img001.jpg")
im2 = Image.new("RGBA",(im1.size[0]*allongement, im1.size[1]*allongement))
largeur = im1.size[0]
hauteur = im1.size[1]
positiony = 0
for x in range(0,allongement):
positionx = 0
for y in range(1,11):
z = x*10 + y
im1 = Image.open("./captain/img%03.1i.jpg" % z)
print "z="+str(z)
im2.paste(im1, (positionx,positiony))
#print position
#print("./drone/img%03.1i.jpg" % x)
positionx = positionx + largeur
print "px"+str(positionx)
positiony = positiony + hauteur
print "py"+str(positiony)
#scriptpy = str(sys.argv[1])
#script = scriptpy[:-3]
im2.save(script+"/"+str(x)+".2.png",'PNG', quality=100)
'''
1145 ffmpeg -i noir...png.mp4 noir...png.enscribe.norm.wav -c:a copy -c:v copy noir..HQ..mp4
1146 ffmpeg -i noir...png.mp4 -i noir...png.enscribe.norm.wav -c:a copy -c:v copy noir..HQ..mp4
1147 ffmpeg -i noir...png.mp4 -i noir...png.enscribe.norm.wav -c:a aac -c:v copy noir..HQ..mp4
1148 ffmpeg -i noir...png.mp4 -i noir...png.enscribe.norm.wav -c:a libfaac -c:v copy noir..HQ..mp4
1158 ffmpeg -i pylone3.png.mp4 -i pylone3.png.enscribe.norm.wav -c:a libfaac -c:v copy pylone3.HQ.mp4
1162 ffmpeg -i pylone3.HQ.mp4
1163 ffmpeg -i pylone3.png.mp4 -i pylone3.png.enscribe.norm.wav -c:a libfaac -c:v copy pylone3.HQ.mp4
1177 ffmpeg -i horizontal%d.png -i pylone3.png.enscribe.norm.wav -c:a libfaac -c:v libx264 -preset ultrafast -crf 32 final.mp4
1178 ffmpeg -i horizontal%d.png -i pylone3.png.enscribe.norm.wav -c:a libfaac -c:v libx264 -b:v 5000k final2.mp4
1179 ffmpeg -i horizontal%d.png -i pylone3.png.enscribe.norm.wav -c:a libfaac -c:v libx264 -vf format=gray -b:v 5000k final2.mp4
1180 ffmpeg -i horizontal%d.png -i pylone3.png.enscribe.norm.wav -c:a libfaac -c:v libx264 -vf format=gray -b:v 5000k final3.mp4
1181 ffmpeg -i horizontal%d.png -i pylone3.png.enscribe.norm.wav -c:a libfaac -c:v libx264 -pix_fmt monow final3.mp4
1182 ffmpeg -i horizontal%d.png -i pylone3.png.enscribe.norm.wav -c:a libfaac -c:v mjpeg -b:v 3000 final4.avi
1183 ffmpeg -q:v
1184 ffmpeg -q:v 0
1186 ffmpeg -pix_fmts
1265 ffmpeg -pix_fmts
1266 ffmpeg -pix_fmts | grep H
1321 history | grep ffmpeg
1323 nano ffmpeg_one_liner
1403 ffmpeg -i Ajja_Tulpa_Full_Album.webm -vn -ar 44100 -ac 2 -ab 192k -f mp3 Ajja_Tulpa_Full_Album.mp3
1404 ffmpeg -i Ajja_Tulpa_Full_Album.webm -vn -ar 44100 -ac 2 -ab 192k -acodec copy Ajja_Tulpa_Full_Album.ogg
1770 ffmpeg ffmpeg -i test0%4d.jpg -vcodec mjpeg out.avi
1771 ffmpeg -i test0%4d.jpg -vcodec mjpeg out.avi
1774 ffmpeg -i out.avi -c:v libvpx -crf 10 -b:v 2M -threads 4 out.webm
1916 ffmpeg -i drone.mp4 -vf fps=1 ./drone/img%03d.jpg
1917 ffmpeg -i drone.mp4 -vf fps=4 ./drone/img%03d.jpg
1918 ffmpeg -i drone.mp4 -vf fps=20 ./drone/img%03d.jpg
1922 ffmpeg -i drone.mp4 -vf fps=30 ./drone/img%03d.jpg
1943 ffmpeg -i drone.mp4 -vf fps=20 ./images_yatil/img%03d.jpg
1946 ffmpeg -i yatil.mkv -vf fps=1 ./images_yatil/img%03d.jpg
1952 ffmpeg -i final.mp4 -v:c h264 -a:c copy tintin.mpeg
1953 ffmpeg -i final.mp4 -v:c libvpx -a:c copy tintin.mpeg
1954 ffmpeg -i final.mp4 -v:c libvpx -a:c copy tintin.mpeg
1956 ffmpeg -i final.mp4 -c:v libvpx -crf 10 -b:v 2M -threads 4 final.webm
1958 ffmpeg -formats
1959 ffmpeg -formats | grep DE
1975 ffmpeg -i drone.mp4
2006 history | grep ffmpeg
2009 history | grep ffmpeg
'''