Skip to content
Snippets Groups Projects
Commit 7f0ceec6 authored by Louis Chmielewski's avatar Louis Chmielewski
Browse files

est_bloc_uniforme class Bloc redéfinition

parent cf354acf
Branches
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
File moved
File moved
File moved
File moved
......@@ -10,6 +10,7 @@
"""
from PIL import Image, ImageDraw
from bloc import Bloc
def decoupe_image(image: Bloc, ordre: int) -> Bloc:
"""
......@@ -19,12 +20,12 @@ def decoupe_image(image: Bloc, ordre: int) -> Bloc:
$$$
"""
image = Image.open(image)
x = ?
y = ?
if 0 <= x < largeur and 0 <= y < hauteur:
pixel = image.getpixel((x, y))
if ordre != 0:
# image = Image.open(image)
# x = ?
# y = ?
# if 0 <= x < largeur and 0 <= y < hauteur:
# pixel = image.getpixel((x, y))
#
# if ordre != 0:
\ No newline at end of file
No preview for this file type
......@@ -17,14 +17,14 @@ class Bloc:
"""Classe d'un bloc d'une image en pixel
"""
def __init__(self, image: Image):
def __init__(self, bloc: Image):
"""
Initialise le type bloc à la valeur de l'image
"""
largeur, hauteur = image.size
pixel_hl = image.getpixel((0, 0))
pixel_lr = image.getpixel((largeur, hauteur))
self.image = image
self.bloc = bloc
def __eq__(self, other):
"""
......@@ -34,17 +34,19 @@ class Bloc:
$$$
"""
return self.image == other.image
return self.bloc == other.bloc
def est_bloc_uniforme(bloc:Bloc)->bool:
def est_bloc_uniforme(bloc1:Bloc, bloc2:Bloc, bloc3:Bloc, bloc4:Bloc)->bool:
"""
Renvoie True si le bloc est un bloc uniforme
Renvoie True si le bloc est un bloc uniforme, c'est à dire si les 4 couleurs du bloc sont proches
Précondition : aucune
Exemple(s) :
$$$
"""
return bloc.pixel_hl == bloc.pixel_lr
return est_couleur_proche(moyenne_couleur_bloc(bloc1), moyenne_couleur_bloc(bloc2)) and \n
est_couleur_proche(moyenne_couleur_bloc(bloc1), moyenne_couleur_bloc(bloc3)) and \n
est_couleur_proche(moyenne_couleur_bloc(bloc1), moyenne_couleur_bloc(bloc4))
def est_bloc_non_uniforme()-> bool:
......
......@@ -17,6 +17,8 @@ def moyenne_couleur_bloc(liste: list[tuple[int,int,int]]) -> tuple:
Exemple(s) :
$$$ moyenne_couleur_bloc([(1,2,3),(4,5,6),(7,8,9)])
(4,5,6)
$$$ moyenne_couleur_bloc([(1,2,3),(4,5,6),(7,8,9),(10,11,12),(13,14,15)])
(7,8,9)
"""
total_r = 0
total_g = 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment