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

liste_col change

parent f7e65e07
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,45 @@ def decouper(file: str) -> list[Image]: ...@@ -25,6 +25,45 @@ def decouper(file: str) -> list[Image]:
l = [block_1, block_2, block_3, block_4] l = [block_1, block_2, block_3, block_4]
return l return l
def avg_col(l:list[int]) -> list[int]:
"""déterminer la couleur moyenne d'une liste de couleurs
Précondition :
Exemple(s) :
$$$
"""
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
return (avg1, avg2, avg3)
def liste_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))
[(236, 210, 111), (236, 210, 111), (236, 210, 111), (236, 210, 111)]
"""
x_min, y_min = left_top
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')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment