From 8e06e61f3fd4cfab3f16f66e186abeee7a4cabf1 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 15 Jan 2019 19:40:02 +0100 Subject: dir --- crop_frames.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'crop_frames.py') diff --git a/crop_frames.py b/crop_frames.py index 2462e7b..7f42d47 100644 --- a/crop_frames.py +++ b/crop_frames.py @@ -9,7 +9,6 @@ from PIL import Image parser = argparse.ArgumentParser() parser.add_argument('--step', default=256, type=int) parser.add_argument('--overlap', default=2, type=int) -parser.add_argument('--scale', default=4, type=int) parser.add_argument('--in_dir', help='Directory to process') parser.add_argument('--out_dir', default='crops', help='Directory to output to') args = parser.parse_args() @@ -19,7 +18,7 @@ def crop_dir(): overlap = args.overlap side = step + overlap * 2 files = glob.glob('{}/*.png'.format(args.in_dir)) - print(files) + # print(files) img = Image.open(files[0]) width, height = img.size -- cgit v1.2.3-70-g09d2 From 580f27bcc5a176fb6a836b83c53475c8a630c659 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 15 Jan 2019 19:47:43 +0100 Subject: fix --- crop_frames.py | 4 ++-- merge_frames.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'crop_frames.py') diff --git a/crop_frames.py b/crop_frames.py index 7f42d47..e3641df 100644 --- a/crop_frames.py +++ b/crop_frames.py @@ -29,7 +29,7 @@ def crop_dir(): yy = max(0, y - overlap) w = min(side, width - xx) h = min(side, height - yy) - crop_dir = "{}/crop_{}_{}_{}_{}".format(args.out_dir, xx, yy, w, h) + crop_dir = "{}/crop_{}_{}_{}_{}".format(args.out_dir, x, y, w, h) if os.path.exists(crop_dir): rmtree(crop_dir) os.makedirs(crop_dir) @@ -51,7 +51,7 @@ def crop_image(raw_fn, width, height, step, side, overlap): yy = max(0, y - overlap) w = min(side, width - xx) h = min(side, height - yy) - crop_dir = "{}/crop_{}_{}_{}_{}".format(args.out_dir, xx, yy, w, h) + crop_dir = "{}/crop_{}_{}_{}_{}".format(args.out_dir, x, y, w, h) # print("{}x{} {}x{}".format(x, y, w, h)) crop = img.crop((xx, yy, xx + w, yy + h)) crop.save("{}/{}".format(crop_dir, fn)) diff --git a/merge_frames.py b/merge_frames.py index ed7b9ff..c413b97 100644 --- a/merge_frames.py +++ b/merge_frames.py @@ -25,7 +25,7 @@ def merge_files(file, crop_dir_list, ww, hh, overlap, merge_dir): crop_dir = "crop_{}_{}_{}_{}".format(x, y, w, h) image = Image.open("{}/{}/{}".format(args.dir, crop_dir, fn)) crop = image.crop((overlap, overlap, image.size[0] - overlap * 2, image.size[1] - overlap * 2)) - canvas.paste(image, (x * args.scale, y * args.scale,)) + canvas.paste(crop, (x * args.scale, y * args.scale,)) canvas.save("{}/{}".format(merge_dir, fn)) def merge_dir(): @@ -48,11 +48,11 @@ def merge_dir(): crop_dir_list.append((x, y, w, h,)) crop_dir_list = sorted(crop_dir_list, key=operator.itemgetter(0, 1)) - print("{}x{}".format(ww, hh)) - ww *= args.scale hh *= args.scale + print("{}x{}".format(ww, hh)) + files = sorted(glob.glob("{}/*.png".format(crop_dirs[0]))) dataset = [] for file in files: -- cgit v1.2.3-70-g09d2