diff --git a/projet/Decouper_Image.py b/projet/Decouper_Image.py index 822912d586e03cdd4bd72e14abec38c60ac5d6c9..b25e02153c508e8633695e4686e9a514f207b535 100644 --- a/projet/Decouper_Image.py +++ b/projet/Decouper_Image.py @@ -25,32 +25,28 @@ def decouper(file: str) -> list[Image]: l = [block_1, block_2, block_3, block_4] return l -def avg_col(l:tuple) -> list[int]: +def avg_col(l:list) -> tuple(): """renvoie la couleur moyenne d'une liste de couleurs Précondition : Exemple(s) : - $$$ + $$$ avg_col([(236, 210, 111), (236, 210, 111), (236, 210, 111), (236, 210, 111)]) + (236, 210, 111) """ - n_col = len(l) - if n_col == 0: - return None - else: - c1 = 0 - c2 = 0 - c3 = 0 - for i in l: - c1 = c1 + l[0] - c2 = c2 + l[1] - c3 = c3 + l[2] - avg1 = c1 / n_col - avg2 = c2 / n_col - avg3 = c3 / n_col + c1 = 0 + c2 = 0 + c3 = 0 + for col in l: + c1 += col[0] + c2 += col[1] + c3 += col[2] + avg1 = c1 // len(l) + avg2 = c2 // len(l) + avg3 = c3 // len(l) return (avg1, avg2, avg3) - def list_col(im: Image, left_top: tuple(), right_bottom: tuple()) -> list[int]: """à_remplacer_par_ce_que_fait_la_fonction @@ -65,8 +61,8 @@ def list_col(im: Image, left_top: tuple(), right_bottom: tuple()) -> list[int]: return [im.getpixel((x, y)) for x in range(x_max+1) for y in range(y_max+1)] def is_col_close(color1: tuple(), color2: tuple()) -> bool: - """returns True if the distance between two colors is not more than 50, - returns False if the distance is more than 50 + """returns True if the distance between two colors is not more than 30, + returns False if the distance is more than 30 Précondition : Exemple(s) :