From f53d5ab7c14c4c1a533a94551be0c8090b2b9cfa Mon Sep 17 00:00:00 2001 From: Dark-Storm Date: Sat, 18 Aug 2018 19:54:38 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20:=20=C3=A0=20m=C3=AAme=20ef?= =?UTF-8?q?ficacit=C3=A9=20on=20prend=20le=20trait=20le=20moins=20long?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- process.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/process.py b/process.py index 3b3a102..42a776a 100755 --- a/process.py +++ b/process.py @@ -88,7 +88,7 @@ def get_best_solution(img, lines): print("Draw:", end = "") while len(px_left): - lines = [(sum([1 for p in l if p in px_left]), l) for n, l in lines] + lines = [(sum([1 for p in l if p in px_left]) - len(l)/(2*max(img.size)), l) for n, l in lines] lines = sorted(lines) (p, line) = lines.pop() px_left = [p for p in px_left if p not in line] @@ -104,7 +104,7 @@ def get_best_solution(img, lines): if __name__ == "__main__": parser = ArgumentParser(description='Generate the Multi DrawStat code for an image.') parser.add_argument('path', type=str, help='path of the image to process') - parser.add_argument('-d', '--draw', type=bool, default=False, help='draw the result into a new file and display it') + parser.add_argument('-d', '--draw', action='store_true', help='draw the result into a new file and display it') args = parser.parse_args() @@ -124,7 +124,7 @@ if __name__ == "__main__": lines = removing_useless(lines) r = get_best_solution(image, lines) - if draw: + if args.draw: export = Image.new('RGB', image.size, 'white') drawer = ImageDraw.Draw(export) for ((a, b), (c, d)) in reversed(r):