summaryrefslogtreecommitdiff
path: root/crop_frames.py
diff options
context:
space:
mode:
authorjules <jules@asdf.us>2019-01-15 19:48:01 +0100
committerjules <jules@asdf.us>2019-01-15 19:48:01 +0100
commit386386473d905f4f7b03daa02cfecdadfc78b631 (patch)
tree6ec947fefce91d24a172ad89198eeb490e5156dc /crop_frames.py
parent2d46492571b263aa79110454016ac0a0a4091db9 (diff)
parent580f27bcc5a176fb6a836b83c53475c8a630c659 (diff)
Merge branch 'master' of asdf.us:vsr-duf
Diffstat (limited to 'crop_frames.py')
-rw-r--r--crop_frames.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/crop_frames.py b/crop_frames.py
index d939d9d..c22adb4 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='inputs', 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
@@ -30,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)
@@ -52,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))