File size: 2,813 Bytes
9affda1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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)

    # 统一高度对齐 (以 1000px 为基准高度进行 Lanczos 高质量重采样)
    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)

    # 设置画布,保持两个 Panel 的原始宽高比比例
    fig, (ax1, ax2) = plt.subplots(
        1, 2, 
        figsize=(16, 5), 
        gridspec_kw={'width_ratios': [aspect_l, aspect_r]}
    )
    
    # 绘制 Left Panel
    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')

    # 绘制 Right Panel
    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" 
    
    # 自动保存到论文的 tex figures 目录
    OUTPUT_PREFIX = "/root/autodl-tmp/SplatAtlas/tex/figures/fig1_saturation_puzzle"
    
    compose_figure_1(LEFT_PATH, RIGHT_PATH, OUTPUT_PREFIX)