# Critique: crop the same sheet region from the sheet and the model's lookalike render, side by side, enlarged import sys, os from PIL import Image, ImageDraw ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) BOX = {"side": (430, 255, 1010, 520), "top": (440, 20, 1000, 250), "bottom": (440, 520, 1000, 745), "front": (95, 215, 385, 550), "back": (1075, 235, 1345, 550)} view, x0, y0, x1, y1, z, name = sys.argv[1], *map(int, sys.argv[2:6]), int(sys.argv[6]), sys.argv[7] b = BOX[view] sheet = Image.open(os.path.join(ROOT, "reference", "user_blueprint.jpg")).convert("RGB") ref = sheet.crop((x0, y0, x1, y1)).resize(((x1-x0)*z, (y1-y0)*z), Image.LANCZOS) lk = Image.open(os.path.join(ROOT, "previews", "compare", "lk_%s.png" % view)).convert("RGBA").resize(((b[2]-b[0])*2, (b[3]-b[1])*2), Image.LANCZOS) bg = Image.new("RGBA", lk.size, (205, 208, 212, 255)); bg.alpha_composite(lk) K = 2 mod = bg.crop(((x0-b[0])*K, (y0-b[1])*K, (x1-b[0])*K, (y1-b[1])*K)).resize(ref.size, Image.LANCZOS) out = Image.new("RGB", (ref.width*2+10, ref.height), (20, 20, 20)) out.paste(ref, (0, 0)); out.paste(mod.convert("RGB"), (ref.width+10, 0)) d = ImageDraw.Draw(out) # ruler ticks every 10 sheet px for xx in range(((x0+9)//10)*10, x1, 10): for off in (0, ref.width+10): X = off + (xx-x0)*z d.line([X, 0, X, 6], fill=(255, 255, 0)); d.text((X+1, 7), str(xx), fill=(255, 255, 0)) for yy in range(((y0+9)//10)*10, y1, 10): for off in (0, ref.width+10): Y = (yy-y0)*z d.line([off, Y, off+6, Y], fill=(255, 255, 0)); d.text((off+8, Y-5), str(yy), fill=(255, 255, 0)) out.save(os.path.join(ROOT, "critique", "round1", name)) print(out.size)