Skip to content
Snippets Groups Projects
Commit 743e1cc3 authored by Kinadinova Dariya's avatar Kinadinova Dariya
Browse files

liste_col

parent 6735258c
No related branches found
No related tags found
No related merge requests found
from PIL import Image, ImageDraw from PIL import Image, ImageDraw
# im = Image.open("calbuth.png")
# im_rgb = im.convert('RGB')
def decouper(im: Image, file: str): def decouper(file: str) -> list[Image]:
"""à_remplacer_par_ce_que_fait_la_fonction """splits image into four blocks
Précondition : Précondition :
Exemple(s) : Exemple(s) :
...@@ -23,4 +21,8 @@ def decouper(im: Image, file: str): ...@@ -23,4 +21,8 @@ def decouper(im: Image, file: str):
crop3 = (0, (h//2), (w//2), h) crop3 = (0, (h//2), (w//2), h)
block_3 = im.crop(crop3) block_3 = im.crop(crop3)
crop4 = ((h//2), (w//2), h, w) crop4 = ((h//2), (w//2), h, w)
block_4 = im.crop(crop4) block_4 = im.crop(crop4)
\ No newline at end of file l = [block_1, block_2, block_3, block_4]
return l
...@@ -28,23 +28,13 @@ def avg_col(l:list[int]) -> list[int]: ...@@ -28,23 +28,13 @@ def avg_col(l:list[int]) -> list[int]:
avg3 = c3 / n_col avg3 = c3 / n_col
return (avg1, avg2, avg3) return (avg1, avg2, avg3)
def is_close(c1: int, c2: int, seuil: int) -> bool: def liste_col(im: Image, left_top: tuple(int), right_bottom: tuple(int)) -> list[int]:
"""savoir si deux couleurs sont proches """à_remplacer_par_ce_que_fait_la_fonction
Précondition : Précondition :
Exemple(s) : 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment