| import matplotlib.pyplot as plt |
| from PIL import Image |
| import os |
|
|
| def compose_figure_1(left_path, right_path, output_prefix): |
| if not os.path.exists(left_path): |
| print(f"❌ 找不到左图: {left_path} \n👉 请手动修改脚本底部的 LEFT_PATH") |
| return |
| if not os.path.exists(right_path): |
| print(f"❌ 找不到右图: {right_path} \n👉 请手动修改脚本底部的 RIGHT_PATH") |
| return |
|
|
| |
| img_l = Image.open(left_path) |
| img_r = Image.open(right_path) |
|
|
| |
| target_height = 1000 |
| aspect_l = img_l.width / img_l.height |
| aspect_r = img_r.width / img_r.height |
| |
| new_w_l = int(target_height * aspect_l) |
| new_w_r = int(target_height * aspect_r) |
|
|
| img_l = img_l.resize((new_w_l, target_height), Image.Resampling.LANCZOS) |
| img_r = img_r.resize((new_w_r, target_height), Image.Resampling.LANCZOS) |
|
|
| |
| fig, (ax1, ax2) = plt.subplots( |
| 1, 2, |
| figsize=(16, 5), |
| gridspec_kw={'width_ratios': [aspect_l, aspect_r]} |
| ) |
| |
| |
| ax1.imshow(img_l) |
| ax1.axis('off') |
| ax1.set_title("(a) Per-seed PSNR Rank Instability (BONSAI & LEGO)", |
| fontsize=16, pad=12, loc='left', fontweight='bold') |
|
|
| |
| ax2.imshow(img_r) |
| ax2.axis('off') |
| ax2.set_title("(b) Saturated Cluster: Render vs. Representation", |
| fontsize=16, pad=12, loc='left', fontweight='bold') |
|
|
| |
| plt.subplots_adjust(wspace=0.03) |
| |
| |
| os.makedirs(os.path.dirname(output_prefix), exist_ok=True) |
| pdf_path = f"{output_prefix}.pdf" |
| png_path = f"{output_prefix}.png" |
| |
| plt.savefig(pdf_path, dpi=300, bbox_inches='tight', format='pdf', transparent=True) |
| plt.savefig(png_path, dpi=300, bbox_inches='tight', format='png', transparent=False) |
| |
| print(f"=== Figure 1 (Saturation Puzzle) 拼图合成完毕 ===") |
| print(f"✅ Saved PDF: {pdf_path} (供 LaTeX 插入)") |
| print(f"✅ Saved PNG: {png_path} (供快速预览)") |
|
|
| if __name__ == "__main__": |
| |
| |
| |
| LEFT_PATH = "/root/autodl-tmp/SplatAtlas/outputs/phase5b/fig1_left_panel.png" |
| RIGHT_PATH = "/root/autodl-tmp/SplatAtlas/outputs/phase5b/image_1ae31e.jpg" |
| |
| |
| OUTPUT_PREFIX = "/root/autodl-tmp/SplatAtlas/tex/figures/fig1_saturation_puzzle" |
| |
| compose_figure_1(LEFT_PATH, RIGHT_PATH, OUTPUT_PREFIX) |
|
|