-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhackathon_barreplace.py
More file actions
59 lines (47 loc) · 2.02 KB
/
Copy pathhackathon_barreplace.py
File metadata and controls
59 lines (47 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from PIL import Image
##from IPython.display import display
import urllib.request
#programme fait par Nicolas vdv
# ouvrir une image hébergée sur internet
im = Image.open(urllib.request.urlopen('https://raw.githubusercontent.com/hackathon-nsi/h7n-nsi-01/main/images/washington.bmp'))
im_3=Image.open("Capture_hackathon.PNG")
# créer une nouvelle image vide
# le deuxième argument représente la taille de l'image et le troisième argument (optionnel) la couleur de remplissage au format RVB
im_new = Image.new("RGB", (500, 500), (255, 255, 255))
# informations sur l'image
print(im_3.format, im_3.size, im_3.mode)
# taille de l'image
width, height = im.size
# valeurs du pixel de coordonnées x, y (l'origine (0, 0) est en haut à gauche)
def barreplace ():
for y in range(0,448):
for x in range(0,356):
pixel = im_3.getpixel((x, y))
p_rouge = pixel[0]
p_vert = pixel[1]
p_bleu = pixel[2]
#if change taille de bande
#x change la distance bande-reste (si deplacement à l'arriere de premiere bande x=x-(distance attendue-1) )
#y monte/decent la barre
if 49<x<100:
im_new.putpixel((x+50,y+10),(p_rouge,p_vert,p_bleu))
elif 99<x<150:
im_new.putpixel((x-50,y+5),(p_rouge,p_vert,p_bleu))
elif 149<x<200:
im_new.putpixel((x+100,y+10),(p_rouge,p_vert,p_bleu))
elif 199<x<250:
im_new.putpixel((x,y+5),(p_rouge,p_vert,p_bleu))
elif 249<x<300:
im_new.putpixel((x-100,y+10),(p_rouge,p_vert,p_bleu))
else:
im_new.putpixel((x,y),(p_rouge,p_vert,p_bleu))
# valeurs des couleurs rouge, vert, bleu
##p_rouge = pixel[0]
##p_vert = pixel[1]
##p_bleu = pixel[2]
# modification du pixel de coordonnées x, y
#im.putpixel((x,y),(r,g,b))
# affichage de l'image
#im.show()
barreplace()
im_new.show() ##im_3.show()