Browse Source

Version bataille navale

rep 5 years ago
parent
commit
b13dace596
6 changed files with 12171 additions and 378 deletions
  1. 10
    2
      .gitignore
  2. 111
    23
      hacheuur.py
  3. 0
    8
      horizontal.simple.py
  4. 40
    0
      pixelate.py
  5. 11899
    345
      test.pickle
  6. 111
    0
      video2d.py

+ 10
- 2
.gitignore View File

@@ -1,2 +1,10 @@
1
-pylone3
2
-test
1
+captain/
2
+drone/
3
+pln/
4
+pylone3/
5
+screen/
6
+test/
7
+tth/
8
+drone.mp4
9
+drone.2.mp4
10
+test.jpg2015-09-29-21h22m05s.jpg

+ 111
- 23
hacheuur.py View File

@@ -6,6 +6,14 @@
6 6
 # image source : pln.jpg
7 7
 # image obtenue : pln..20150910-11h59m53s.jpg
8 8
 
9
+# pln.png 3936x1024 pix
10
+
11
+'''
12
+image input puredata : 16384 width x 768 height
13
+donc par exemple, pour 3 images :
14
+3 x 16384 = 49152 pixels en tout
15
+'''
16
+
9 17
 import sys
10 18
 import Image
11 19
 import random
@@ -16,24 +24,31 @@ import ImageFilter
16 24
 from time import gmtime, strftime
17 25
 import time
18 26
 
27
+
28
+if not len(sys.argv) > 1:
29
+    raise SystemExit("Usage: %s image_source" % sys.argv[0])
30
+
19 31
 # modifs du 30/10/2013
20 32
 import ImageEnhance
21 33
 
22
-#ouvertrure de l'image source et conversion en mode couleur 1bit
34
+#ouverture de l'image source et conversion en mode couleur 1bit
23 35
 im1 = Image.open(str(sys.argv[1])).convert('1')
36
+#im1 = Image.open(str(sys.argv[1])).convert('L')
37
+#im1 = Image.open(str(sys.argv[1]))
24 38
 im2 = im1.copy()
25 39
 
26 40
 #rapport d'allongement de la nouvelle image par rapport à la largeur de l'image originale
27
-allongement = 4
41
+allongement = 8
28 42
 
29 43
 im3 = Image.new("RGBA",(im1.size[0], im1.size[1]))
30 44
 im4 = Image.new("RGBA",(im1.size[0]*allongement, im1.size[1]))
45
+#im4 = Image.new("RGBA",(49152, im1.size[1]))
31 46
 
32 47
 Larg = im1.size[0]
33 48
 Haut = im1.size[1]
34 49
 import pickle
35 50
 
36
-loadfile = True
51
+loadfile = False
37 52
 
38 53
 class Sequence:
39 54
 	def __init__(s):
@@ -47,12 +62,13 @@ class Sequence:
47 62
 """
48 63
 seq = dict()
49 64
 seq["randomCoupeHauteur"] = []
50
-seq["randomCopyPosi"] = [] 
65
+seq["randomCopyPosi"] = []
51 66
 seq["proportions"] = []
52 67
 seq["choix"] = []
53 68
 seq["sizeOutput"]= im4.size
54 69
 seq["sizeInput"] = im1.size
55 70
 """
71
+
56 72
 if loadfile:
57 73
 	seq=pickle.load(open("test.pickle"))
58 74
 
@@ -61,16 +77,15 @@ else :
61 77
 	
62 78
 for i in range(1):
63 79
 	
64
-		
65 80
 	# constitution de la liste des tranches horizontales
66 81
 	# genre comme si qu'on avait un 16 pistes :)
67 82
 	# nombre aleatoire compris dans les limites de l'image
68 83
 	def randHaut():
69
-		return random.randint(0, im1.size[1])
70
-	
84
+		return random.randint(0, im1.size[1]/8)*8
85
+
71 86
 	if loadfile:
72 87
 		randomCoupeHauteur = seq.randomCoupeHauteur
73
-		
88
+
74 89
 	else:
75 90
 		randomCoupeHauteur = [0, \
76 91
 		randHaut(),randHaut(),randHaut(),randHaut(), \
@@ -85,62 +100,107 @@ for i in range(1):
85 100
 		# rangement des valeurs des plus petites au plus grandes
86 101
 		randomCoupeHauteur.sort()
87 102
 		seq.randomCoupeHauteur = randomCoupeHauteur
88
-		
103
+
89 104
 	# les hachures
90 105
 	def Hacheur(haut, bas) :
91
-		
106
+
92 107
 		n=0
93 108
 		i=0
94 109
 		#!!!!!!!!!!
95 110
 		while n<im4.size[0] :
96
-			
97 111
 			if loadfile:
98 112
 				proportions = seq.proportions
99 113
 				choix_rnd = seq.choix[i]
100 114
 				randomCopyPosi = seq.randomCopyPosi[i]
101 115
 			else:
102
-				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)]
116
+
117
+				'''
118
+				8 16 24 32 40 48 56 64 72 80 88 96 104 112 120 128 136 144 152 160 168
119
+				'''
120
+
121
+				#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)]
122
+				#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)]
123
+				#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)]
124
+
125
+				proportions = [(256,1),(160,1),(120,2),(120,3),(80,6),(64,12),(24,18),(8,24),(8,16)]
126
+
127
+				#proportion pln pour output final avec puredata/gem (decalage phase 32pix)
128
+				
129
+				'''
130
+				proportions = [	(768,2),\
131
+								(512,4),\
132
+								(256,8),\
133
+								(128,4),(128,16),\
134
+								(64,4),(64,8),(64,16),\
135
+								(32,8),(32,16),(32,32),(32,32),(32,64),(32,128),\
136
+								(16,1),(16,4),(16,16),(16,64)]
137
+				'''
138
+				#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)]
139
+				#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)]
140
+				
103 141
 				seq.proportions = proportions
104 142
 				#proportions = seq.proportions[]
105 143
 				choix_rnd = random.randint(0, len(proportions)-1)
106 144
 				#choix_rnd = random.randint(0, len(proportions)-1)
107 145
 				seq.choix.append(choix_rnd)
108
-	
146
+				
147
+				largeur = proportions[choix_rnd][0]
109 148
 				
110 149
 				# positionnement de la copie, aleatoirement, entre 0 et la largeur totale de l'image 
111 150
 				randomCopyPosi = random.randint(0, (im1.size[0]-largeur))
112 151
 				#randomCopyPosi = seq.randomCopyPosi
113 152
 				seq.randomCopyPosi.append(randomCopyPosi)
114
-			
115
-			i+=1
116 153
 
154
+			i+=1
155
+			
117 156
 			# tirage au sort
118 157
 
119
-			
120 158
 			#seq["choix"].append(choix_rnd)
121
-			
159
+
122 160
 			# assignation des valeurs (paires) finales choisies
123 161
 			largeur = proportions[choix_rnd][0]			
124 162
 			repeat = proportions[choix_rnd][1]
125
-	
126 163
 
127 164
 			#seq["randomCopyPosi"].append(randomCopyPosi)
128
-			
165
+
129 166
 			cx1 = randomCopyPosi
130 167
 			cx2 = randomCopyPosi + largeur
131 168
 			# decoupage du sample
132 169
 			im3 = im2.crop((cx1,haut,cx2,bas))
170
+						
171
+			print "im3 = im2.crop : "+str(im3.size)
133 172
 				
134
-			draw = ImageDraw.Draw(im4)		
173
+			draw = ImageDraw.Draw(im4)
174
+					
135 175
 			loop = 0
136 176
 			
137
-			#collage, n fois, du sample
177
+			pixelSizeList = [1,1,1,1,1,1,1,1,4,8]
178
+			#pixelSizeList = [1]
179
+			pixelSizeIndex = random.randint(0,len(pixelSizeList)-1)
180
+			pixelSize = pixelSizeList[pixelSizeIndex]
181
+			'''
182
+			print " pixelSize = "+str(pixelSize)
183
+			'''
184
+			
185
+			''' COLLAGE DU SAMPLE
186
+			'''
138 187
 			while loop<repeat:	
139 188
 				px1 = n
140 189
 				px2 = n + largeur
141 190
 				
142 191
 				draw = ImageDraw.Draw(im3)
143 192
 				
193
+				''' PIXELISATION
194
+				'''
195
+
196
+				im3 = im3.resize((im3.size[0]/pixelSize, im3.size[1]/pixelSize), Image.NEAREST)
197
+				im3 = im3.resize((im3.size[0]*pixelSize, im3.size[1]*pixelSize), Image.NEAREST)
198
+				
199
+				'''
200
+				print "im3.size="+str(im3.size)
201
+				print "im4.size="+str(im4.size)
202
+				'''
203
+				
144 204
 				#lignes colorées de 1 pix
145 205
 				draw.line((im3.size[0]-1, 0, im3.size[0]-1, im3.size[1]-1), fill="rgb(255,255,255)")
146 206
 				
@@ -148,7 +208,9 @@ for i in range(1):
148 208
 				
149 209
 				n = n + largeur
150 210
 				loop = loop + 1
151
-		
211
+	
212
+	''' OPTIONS
213
+	'''	
152 214
 	def TrancheHorizontale() :
153 215
 		# tirage au hasard de la bande copiee
154 216
 		pos = random.randint(0, im1.size[1]-im1.size[1]/20)
@@ -167,6 +229,9 @@ for i in range(1):
167 229
 	for j in range(len(randomCoupeHauteur)-1):
168 230
 		Hacheur(randomCoupeHauteur[j], randomCoupeHauteur[j+1])
169 231
 	
232
+	''' SAUVEGARDE	
233
+	'''
234
+	
170 235
 	# CTRL + S
171 236
 	#chemin du script	: scriptpy = sys.argv[0]
172 237
 	#chemin de l'image	: str(sys.argv[1])
@@ -179,4 +244,27 @@ for i in range(1):
179 244
 	#print script+"."+str(i)+"_"+strftime("%Y%m%d-%Hh%Mm%Ss", gmtime())+".jpg"
180 245
 	#millis = int(round(time.time() * 1000))
181 246
 	#print "millis-secondes : "+str(millis)
182
-	
247
+
248
+
249
+#obtenir les valeurs RGB des pixels de l'image
250
+'''
251
+from PIL import Image
252
+
253
+im = Image.open('test.png')
254
+pixels = list(im.getdata())
255
+width, height = im.size
256
+
257
+pixels = [pixels[i * width:(i + 1) * width] for i in xrange(height)]
258
+
259
+for r in range(0, height-⁠1) :
260
+        print "pixels = "+str(pixels[r])
261
+
262
+print " "
263
+print "len(pixels) = "+str(len(pixels))
264
+print "width = "+str(width)
265
+print "height = "+str(height)
266
+print " "
267
+
268
+#tintin = im.tostring( "raw", "RGBA", 0, -⁠1)
269
+#print "tostring = "+tintin
270
+'''

+ 0
- 8
horizontal.simple.py View File

@@ -4,7 +4,6 @@ from time import gmtime, strftime
4 4
 
5 5
 fichier=sys.argv[1]
6 6
 
7
-
8 7
 try:
9 8
 	im1 = Image.open(fichier).convert('1')
10 9
 	im2 = im1.copy()
@@ -27,7 +26,6 @@ while x < im1.size[0] :
27 26
 		
28 27
 	# ALPHA tout bete :
29 28
 	im3 = Image.blend(im1, im2, 0.8)
30
-
31 29
 	
32 30
 	n = "%05d" % x
33 31
 	nomdefichier = "horizontal"+n+".png"
@@ -43,9 +41,3 @@ print " OUTPUT FINAL : "+fichier+".final.mp4"
43 41
 
44 42
 # Nettoyage
45 43
 os.system("rm horizontal*.png")
46
-
47
-
48
-		
49
-	
50
-	
51
-	

+ 40
- 0
pixelate.py View File

@@ -0,0 +1,40 @@
1
+from PIL import Image
2
+
3
+'''
4
+backgroundColor = (0,)*3
5
+'''
6
+
7
+pixelSize = 8
8
+
9
+image = Image.open('pixelate_input.png')
10
+image = image.resize((image.size[0]/pixelSize, image.size[1]/pixelSize), Image.NEAREST)
11
+image = image.resize((image.size[0]*pixelSize, image.size[1]*pixelSize), Image.NEAREST)
12
+pixel = image.load()
13
+
14
+'''
15
+for i in range(0,image.size[0],pixelSize):
16
+  for j in range(0,image.size[1],pixelSize):
17
+    for r in range(pixelSize):
18
+      pixel[i+r,j] = backgroundColor
19
+      pixel[i,j+r] = backgroundColor
20
+'''
21
+
22
+image.save('pixelate_output.png')
23
+
24
+
25
+'''
26
+load
27
+
28
+im.load()
29
+
30
+Allocates storage for the image and loads it from the file (or from the source, for lazy operations). In normal cases, you don’t need to call this method, since the Image class automatically loads an opened image when it is accessed for the first time.
31
+
32
+(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:
33
+
34
+pix = im.load()
35
+print pix[x, y]
36
+pix[x, y] = value
37
+
38
+Access via this object is a lot faster than getpixel and putpixel.
39
+'''
40
+

+ 11899
- 345
test.pickle
File diff suppressed because it is too large
View File


+ 111
- 0
video2d.py View File

@@ -0,0 +1,111 @@
1
+#!/usr/bin/python
2
+# coding: utf-8
3
+
4
+'''
5
+ffmpeg -i drone.mp4 -vf fps=30 ./drone/img%03d.jpg
6
+'''
7
+
8
+import sys 		# sys.argv[]
9
+import Image 	# Image.open()
10
+import os 		# os.getcwd
11
+
12
+'''
13
+im1 = Image.open(str(sys.argv[1]))
14
+width, height = im1.size
15
+print "width  =% 5.2i" % width
16
+print "height =% 5.2i" % height
17
+allongement = 8
18
+im4 = Image.new("RGBA",(im1.size[0]*allongement, im1.size[1]))
19
+for x in range(1,allongement+1):
20
+    print('%03.1i' % x)
21
+'''
22
+
23
+script = os.getcwd()
24
+print script
25
+
26
+index = 1
27
+allongement = 10	#4818
28
+im1 = Image.open("./captain/img001.jpg")
29
+im2 = Image.new("RGBA",(im1.size[0]*allongement, im1.size[1]*allongement))
30
+largeur = im1.size[0]
31
+hauteur = im1.size[1]
32
+
33
+positiony = 0
34
+
35
+for x in range(0,allongement):	
36
+	positionx = 0
37
+
38
+	for y in range(1,11):
39
+		z = x*10 + y
40
+		im1 = Image.open("./captain/img%03.1i.jpg" % z)
41
+		print "z="+str(z)
42
+		im2.paste(im1, (positionx,positiony))
43
+		#print position
44
+		#print("./drone/img%03.1i.jpg" % x)
45
+		positionx = positionx + largeur
46
+		print "px"+str(positionx)
47
+	positiony = positiony + hauteur
48
+	print "py"+str(positiony)
49
+	#scriptpy = str(sys.argv[1])
50
+	#script = scriptpy[:-3]
51
+
52
+im2.save(script+"/"+str(x)+".2.png",'PNG', quality=100)
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+'''
70
+1145  ffmpeg -i noir...png.mp4 noir...png.enscribe.norm.wav -c:a copy -c:v copy noir..HQ..mp4
71
+ 1146  ffmpeg -i noir...png.mp4 -i noir...png.enscribe.norm.wav -c:a copy -c:v copy noir..HQ..mp4
72
+ 1147  ffmpeg -i noir...png.mp4 -i noir...png.enscribe.norm.wav -c:a aac -c:v copy noir..HQ..mp4
73
+ 1148  ffmpeg -i noir...png.mp4 -i noir...png.enscribe.norm.wav -c:a libfaac -c:v copy noir..HQ..mp4
74
+ 1158  ffmpeg -i pylone3.png.mp4 -i pylone3.png.enscribe.norm.wav -c:a libfaac -c:v copy pylone3.HQ.mp4
75
+ 1162  ffmpeg -i pylone3.HQ.mp4 
76
+ 1163  ffmpeg -i pylone3.png.mp4 -i pylone3.png.enscribe.norm.wav -c:a libfaac -c:v copy pylone3.HQ.mp4
77
+ 1177  ffmpeg -i horizontal%d.png -i pylone3.png.enscribe.norm.wav  -c:a libfaac -c:v libx264 -preset ultrafast -crf 32 final.mp4
78
+ 1178  ffmpeg -i horizontal%d.png -i pylone3.png.enscribe.norm.wav  -c:a libfaac -c:v libx264 -b:v 5000k  final2.mp4
79
+ 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
80
+ 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
81
+ 1181  ffmpeg -i horizontal%d.png -i pylone3.png.enscribe.norm.wav  -c:a libfaac -c:v libx264 -pix_fmt monow  final3.mp4
82
+ 1182  ffmpeg -i horizontal%d.png -i pylone3.png.enscribe.norm.wav  -c:a libfaac -c:v mjpeg -b:v 3000 final4.avi
83
+ 1183  ffmpeg -q:v
84
+ 1184  ffmpeg -q:v 0
85
+ 1186  ffmpeg -pix_fmts
86
+ 1265  ffmpeg -pix_fmts
87
+ 1266  ffmpeg -pix_fmts | grep H
88
+ 1321  history | grep ffmpeg
89
+ 1323  nano ffmpeg_one_liner
90
+ 1403  ffmpeg -i Ajja_Tulpa_Full_Album.webm -vn -ar 44100 -ac 2 -ab 192k -f mp3 Ajja_Tulpa_Full_Album.mp3
91
+ 1404  ffmpeg -i Ajja_Tulpa_Full_Album.webm -vn -ar 44100 -ac 2 -ab 192k -acodec copy Ajja_Tulpa_Full_Album.ogg
92
+ 1770  ffmpeg ffmpeg -i test0%4d.jpg -vcodec mjpeg out.avi
93
+ 1771  ffmpeg -i test0%4d.jpg -vcodec mjpeg out.avi
94
+ 1774  ffmpeg -i out.avi -c:v libvpx -crf 10 -b:v 2M  -threads 4 out.webm
95
+ 1916  ffmpeg -i drone.mp4 -vf fps=1 ./drone/img%03d.jpg
96
+ 1917  ffmpeg -i drone.mp4 -vf fps=4 ./drone/img%03d.jpg
97
+ 1918  ffmpeg -i drone.mp4 -vf fps=20 ./drone/img%03d.jpg
98
+ 1922  ffmpeg -i drone.mp4 -vf fps=30 ./drone/img%03d.jpg
99
+ 1943  ffmpeg -i drone.mp4 -vf fps=20 ./images_yatil/img%03d.jpg
100
+ 1946  ffmpeg -i yatil.mkv -vf fps=1 ./images_yatil/img%03d.jpg
101
+ 1952  ffmpeg -i final.mp4 -v:c h264 -a:c copy tintin.mpeg
102
+ 1953  ffmpeg -i final.mp4 -v:c libvpx -a:c copy tintin.mpeg
103
+ 1954  ffmpeg -i final.mp4 -v:c libvpx -a:c copy tintin.mpeg
104
+ 1956  ffmpeg -i final.mp4 -c:v libvpx -crf 10 -b:v 2M  -threads 4 final.webm
105
+ 1958  ffmpeg -formats
106
+ 1959  ffmpeg -formats | grep DE
107
+ 1975  ffmpeg -i drone.mp4 
108
+ 2006  history | grep ffmpeg
109
+ 2009  history | grep ffmpeg
110
+
111
+'''

Loading…
Cancel
Save