From 743e1cc39c384c1c4ec0ef8ad8a80d2b70de64db Mon Sep 17 00:00:00 2001 From: Kinadinova Dariya <dariya.kinadinova.etu@118p27.fil.univ-lille.fr> Date: Wed, 27 Mar 2024 11:22:29 +0100 Subject: [PATCH] liste_col --- projet/Decouper_Image.py | 12 +++++++----- projet/color.py | 16 +++------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/projet/Decouper_Image.py b/projet/Decouper_Image.py index 15c5257..4c3e0b8 100644 --- a/projet/Decouper_Image.py +++ b/projet/Decouper_Image.py @@ -1,10 +1,8 @@ from PIL import Image, ImageDraw -# im = Image.open("calbuth.png") -# im_rgb = im.convert('RGB') -def decouper(im: Image, file: str): - """à_remplacer_par_ce_que_fait_la_fonction +def decouper(file: str) -> list[Image]: + """splits image into four blocks Précondition : Exemple(s) : @@ -23,4 +21,8 @@ def decouper(im: Image, file: str): crop3 = (0, (h//2), (w//2), h) block_3 = im.crop(crop3) crop4 = ((h//2), (w//2), h, w) - block_4 = im.crop(crop4) \ No newline at end of file + block_4 = im.crop(crop4) + l = [block_1, block_2, block_3, block_4] + return l + + diff --git a/projet/color.py b/projet/color.py index ee5d33e..7ba0a5f 100644 --- a/projet/color.py +++ b/projet/color.py @@ -28,23 +28,13 @@ def avg_col(l:list[int]) -> list[int]: avg3 = c3 / n_col return (avg1, avg2, avg3) -def is_close(c1: int, c2: int, seuil: int) -> bool: - """savoir si deux couleurs sont proches +def liste_col(im: Image, left_top: tuple(int), right_bottom: tuple(int)) -> list[int]: + """à_remplacer_par_ce_que_fait_la_fonction Précondition : Exemple(s) : $$$ """ - dist_2 = 0 - for i in range(3): - dist_2 = dist_2 + (c1[i] - c2[i]) ** 2 - distance = dist_2 ** 0.5 - return distance < seuil - - - - - - \ No newline at end of file + \ No newline at end of file -- GitLab