33 lines
919 B
Python
33 lines
919 B
Python
'''
|
|
REQUIREMENT :
|
|
600x600
|
|
Boucles
|
|
9 images avec couleurs random
|
|
On doit commencer par modifier l'image en niveau de gris et ensuite associer des couleurs à ces valeurs de gris
|
|
|
|
On sait que :
|
|
L'image fait du 600 par 600 -> On sait que la fonction while doit se limiter à 600
|
|
'''
|
|
from PIL import Image # Importe le module Pillow pour manipuler des images
|
|
'''
|
|
import numpy as np # Importe le module numpy, pour avoir un manipulation de nombre plus précises
|
|
'''
|
|
from random import randint
|
|
|
|
chat = Image.open('chat.jpg')
|
|
|
|
base = Image.new("RGB", (600, 600)) # Crée une image qui vas servir de base aux autres
|
|
|
|
|
|
colone, ligne = 600, 600
|
|
count = 0
|
|
for x in range(chat.width):
|
|
for y in range(chat.height):
|
|
R, G, B = chat.getpixel((x, y))
|
|
print(R, G, B)
|
|
gris = round(0.266*R+0.587*G+0.114*B)
|
|
chat.putpixel((x,y),gris )
|
|
print(R, G, B)
|
|
chat.show()
|
|
base.show()
|