Amélioration : à même efficacité on prend le trait le moins long
This commit is contained in:
parent
1dc33c2062
commit
f53d5ab7c1
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue