diff --git a/.DS_Store b/.DS_Store index 314ae6525454bb8cda41d76ab1fb1f8d62dc8f23..55abb228771bf4adbb7bb1ee293e0e714c44a2d5 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Projet/.DS_Store b/Projet/.DS_Store index 012a194f43ef6645fe0c77bd378b13dfb3310c7b..3cc5a085cf80b39596e3e5ea68fb33c5912768bf 100644 Binary files a/Projet/.DS_Store and b/Projet/.DS_Store differ diff --git a/Projet/src/bloc.py b/Projet/src/bloc.py index ae3edca8ae3963771d17439f840c1335f58c0145..f1ab95cb8c99c2977e7caea46328b634b012b287 100755 --- a/Projet/src/bloc.py +++ b/Projet/src/bloc.py @@ -12,40 +12,35 @@ from PIL import Image, ImageDraw +def moyenne_couleur_bloc(liste: list[tuple]) -> tuple: + """ + Renvoie la moyenne de la couleur d'un bloc + Précondition : aucune + Exemple(s) : + $$$ moyenne_couleur_bloc([(1,2,3),(4,5,6),(7,8,9)]) + (4,5,6) + """ + total_r = 0 + total_g = 0 + total_b = 0 + for couleur in liste: + total_r = total_r + couleur[0] + total_g = total_r + couleur[1] + total_b = total_r + couleur[2] + nombre_blocs = len(liste) + moyenne_r = total_r / nombre_blocs + moyenne_g = total_g / nombre_blocs + moyenne_b = total_b / nombre_blocs + return (moyenne_r, moyenne_g, moyenne_b) + class Bloc: """Classe d'un bloc d'une image en pixel """ def __init__(self, image: Image): """ - $$$ + Initialise le type bloc à la valeur de l'image """ self.image = image - - def __repr__(self) -> str: - """ - $$$ repr(DicoTrie([Association('a', 1)])) - "DicoTrie([Association('a', 1)])" - $$$ repr(DicoTrie([Association('a', 1), Association('b', 2)])) - "DicoTrie([Association('a', 1), Association('b', 2)])" - $$$ repr(DicoTrie([Association('c', 3), Association('a', 2), Association('b', 1)])) - "DicoTrie([Association('a', 2), Association('b', 1), Association('c', 3)])" - """ - return f"DicoTrie({repr(self.liste_assos)})" - - def __eq__(self, autre) -> bool: - """ - $$$ d1 = DicoTrie([Association("a", 1), Association("b", 2)]) - $$$ d2 = DicoTrie([Association("b", 2), Association("a", 1)]) - $$$ d3 = DicoTrie([Association("a", 1), Association("b", 2), Association("c", 3)]) - $$$ d1 == d2 - True - $$$ d1 == d3 - False - $$$ d1 == {"a": 1, "b": 2} - False - """ - if isinstance(autre, DicoTrie): - return self.liste_assos == autre.liste_assos - else: - return False \ No newline at end of file + + \ No newline at end of file diff --git a/Tp07/analyse_tris.csv b/Tp07/analyse_tris.csv index 047dc861a8519f12ee7b66dbe66ef9c746af2890..e734b51b76516481613d93c68ce39fe47026adc3 100644 --- a/Tp07/analyse_tris.csv +++ b/Tp07/analyse_tris.csv @@ -3,100 +3,100 @@ taille;"tri séléction";"tri insertion" 1; 0.00; 0.00 2; 1.00; 1.00 3; 3.00; 2.64 - 4; 6.00; 5.00 - 5; 10.00; 7.86 - 6; 15.00; 11.46 - 7; 21.00; 14.70 + 4; 6.00; 4.92 + 5; 10.00; 7.54 + 6; 15.00; 10.94 + 7; 21.00; 15.32 8; 28.00; 19.64 - 9; 36.00; 25.42 - 10; 45.00; 29.94 - 11; 55.00; 35.96 - 12; 66.00; 43.34 - 13; 78.00; 48.08 - 14; 91.00; 53.64 - 15; 105.00; 63.70 - 16; 120.00; 71.38 - 17; 136.00; 83.42 - 18; 153.00; 91.68 - 19; 171.00; 101.96 - 20; 190.00; 115.44 - 21; 210.00; 123.02 - 22; 231.00; 132.92 - 23; 253.00; 142.60 - 24; 276.00; 153.86 - 25; 300.00; 172.64 - 26; 325.00; 184.34 - 27; 351.00; 198.60 - 28; 378.00; 217.44 - 29; 406.00; 225.00 - 30; 435.00; 239.34 - 31; 465.00; 259.34 - 32; 496.00; 280.90 - 33; 528.00; 284.24 - 34; 561.00; 310.76 - 35; 595.00; 325.26 - 36; 630.00; 343.40 - 37; 666.00; 359.78 - 38; 703.00; 375.08 - 39; 741.00; 400.10 - 40; 780.00; 430.74 - 41; 820.00; 452.26 - 42; 861.00; 468.32 - 43; 903.00; 495.84 - 44; 946.00; 507.40 - 45; 990.00; 533.92 - 46; 1035.00; 555.38 - 47; 1081.00; 598.14 - 48; 1128.00; 599.04 - 49; 1176.00; 635.12 - 50; 1225.00; 658.20 - 51; 1275.00; 676.26 - 52; 1326.00; 709.66 - 53; 1378.00; 732.12 - 54; 1431.00; 760.52 - 55; 1485.00; 802.84 - 56; 1540.00; 807.68 - 57; 1596.00; 846.38 - 58; 1653.00; 861.46 - 59; 1711.00; 890.74 - 60; 1770.00; 946.72 - 61; 1830.00; 992.92 - 62; 1891.00; 1023.54 - 63; 1953.00; 1019.50 - 64; 2016.00; 1057.94 - 65; 2080.00; 1086.24 - 66; 2145.00; 1128.60 - 67; 2211.00; 1165.44 - 68; 2278.00; 1204.84 - 69; 2346.00; 1219.90 - 70; 2415.00; 1281.70 - 71; 2485.00; 1316.64 - 72; 2556.00; 1342.46 - 73; 2628.00; 1418.52 - 74; 2701.00; 1405.10 + 9; 36.00; 25.24 + 10; 45.00; 29.92 + 11; 55.00; 36.68 + 12; 66.00; 43.12 + 13; 78.00; 47.28 + 14; 91.00; 55.54 + 15; 105.00; 63.20 + 16; 120.00; 72.32 + 17; 136.00; 82.30 + 18; 153.00; 89.66 + 19; 171.00; 101.32 + 20; 190.00; 112.30 + 21; 210.00; 123.76 + 22; 231.00; 132.08 + 23; 253.00; 148.94 + 24; 276.00; 158.76 + 25; 300.00; 172.68 + 26; 325.00; 181.14 + 27; 351.00; 199.98 + 28; 378.00; 212.36 + 29; 406.00; 227.14 + 30; 435.00; 249.68 + 31; 465.00; 263.34 + 32; 496.00; 277.68 + 33; 528.00; 274.10 + 34; 561.00; 313.86 + 35; 595.00; 330.42 + 36; 630.00; 354.54 + 37; 666.00; 364.18 + 38; 703.00; 390.42 + 39; 741.00; 401.12 + 40; 780.00; 430.32 + 41; 820.00; 446.28 + 42; 861.00; 478.54 + 43; 903.00; 497.62 + 44; 946.00; 510.08 + 45; 990.00; 539.00 + 46; 1035.00; 564.02 + 47; 1081.00; 599.94 + 48; 1128.00; 606.68 + 49; 1176.00; 632.84 + 50; 1225.00; 653.74 + 51; 1275.00; 674.24 + 52; 1326.00; 704.72 + 53; 1378.00; 734.54 + 54; 1431.00; 760.22 + 55; 1485.00; 788.30 + 56; 1540.00; 819.02 + 57; 1596.00; 857.40 + 58; 1653.00; 890.08 + 59; 1711.00; 912.04 + 60; 1770.00; 938.86 + 61; 1830.00; 971.26 + 62; 1891.00; 1025.26 + 63; 1953.00; 1046.14 + 64; 2016.00; 1090.40 + 65; 2080.00; 1096.62 + 66; 2145.00; 1145.48 + 67; 2211.00; 1173.32 + 68; 2278.00; 1189.14 + 69; 2346.00; 1251.80 + 70; 2415.00; 1261.46 + 71; 2485.00; 1306.84 + 72; 2556.00; 1332.00 + 73; 2628.00; 1376.90 + 74; 2701.00; 1417.70 75; 2775.00; 1451.02 - 76; 2850.00; 1518.22 - 77; 2926.00; 1518.80 - 78; 3003.00; 1564.58 - 79; 3081.00; 1623.58 - 80; 3160.00; 1642.04 - 81; 3240.00; 1710.88 - 82; 3321.00; 1745.06 - 83; 3403.00; 1764.28 - 84; 3486.00; 1816.94 - 85; 3570.00; 1854.54 - 86; 3655.00; 1912.42 - 87; 3741.00; 1968.82 - 88; 3828.00; 1975.62 - 89; 3916.00; 2040.76 - 90; 4005.00; 2121.34 - 91; 4095.00; 2139.34 - 92; 4186.00; 2212.86 - 93; 4278.00; 2208.74 - 94; 4371.00; 2274.04 - 95; 4465.00; 2334.48 - 96; 4560.00; 2351.64 - 97; 4656.00; 2429.18 - 98; 4753.00; 2424.46 - 99; 4851.00; 2481.82 -100; 4950.00; 2554.04 + 76; 2850.00; 1518.80 + 77; 2926.00; 1557.62 + 78; 3003.00; 1573.26 + 79; 3081.00; 1628.08 + 80; 3160.00; 1643.72 + 81; 3240.00; 1705.26 + 82; 3321.00; 1735.44 + 83; 3403.00; 1812.70 + 84; 3486.00; 1795.68 + 85; 3570.00; 1870.22 + 86; 3655.00; 1904.20 + 87; 3741.00; 1918.00 + 88; 3828.00; 2008.04 + 89; 3916.00; 2041.26 + 90; 4005.00; 2080.34 + 91; 4095.00; 2129.18 + 92; 4186.00; 2178.48 + 93; 4278.00; 2213.48 + 94; 4371.00; 2246.84 + 95; 4465.00; 2334.28 + 96; 4560.00; 2348.12 + 97; 4656.00; 2408.74 + 98; 4753.00; 2505.40 + 99; 4851.00; 2521.26 +100; 4950.00; 2606.24 diff --git a/Tp07/tris_nbcomp.png b/Tp07/tris_nbcomp.png index d1437223e647c02958e0b2f80200baade2d587cf..63a4200bc70ea4a5c06357b44eb7161e03a6373e 100644 Binary files a/Tp07/tris_nbcomp.png and b/Tp07/tris_nbcomp.png differ