From 806ae18a757081c50b95d26ef0536ee5d64b5117 Mon Sep 17 00:00:00 2001 From: Kinadinova Dariya <dariya.kinadinova.etu@115p4.fil.univ-lille.fr> Date: Wed, 27 Mar 2024 12:25:40 +0100 Subject: [PATCH] is_col_close --- projet/Decouper_Image.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/projet/Decouper_Image.py b/projet/Decouper_Image.py index d2afe32..822912d 100644 --- a/projet/Decouper_Image.py +++ b/projet/Decouper_Image.py @@ -25,8 +25,8 @@ def decouper(file: str) -> list[Image]: l = [block_1, block_2, block_3, block_4] return l -def avg_col(l:list[int]) -> list[int]: - """déterminer la couleur moyenne d'une liste de couleurs +def avg_col(l:tuple) -> list[int]: + """renvoie la couleur moyenne d'une liste de couleurs Précondition : Exemple(s) : @@ -49,12 +49,14 @@ def avg_col(l:list[int]) -> list[int]: avg3 = c3 / n_col return (avg1, avg2, avg3) -def liste_col(im: Image, left_top: tuple(), right_bottom: tuple()) -> list[int]: + + +def list_col(im: Image, left_top: tuple(), right_bottom: tuple()) -> list[int]: """à_remplacer_par_ce_que_fait_la_fonction Précondition : Exemple(s) : - $$$ liste_col(im, (0,0), (1, 1)) + $$$ list_col(Image.open('calbuth.png'), (0,0), (1, 1)) [(236, 210, 111), (236, 210, 111), (236, 210, 111), (236, 210, 111)] """ @@ -62,7 +64,17 @@ def liste_col(im: Image, left_top: tuple(), right_bottom: tuple()) -> list[int]: x_max, y_max = right_bottom return [im.getpixel((x, y)) for x in range(x_max+1) for y in range(y_max+1)] -im = Image.open('calbuth.png') +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 + + Précondition : + Exemple(s) : + $$$ + + """ + + -- GitLab