diff --git a/configs/_tmp_fix_bottom_w1p4.yaml b/configs/_tmp_fix_bottom_w1p4.yaml new file mode 100644 index 0000000..813ea4b --- /dev/null +++ b/configs/_tmp_fix_bottom_w1p4.yaml @@ -0,0 +1,196 @@ +name: bottom_w1p4 +description: 'TEST_12 追補: ロフト w1.4 bottom 単灯(面法線修正後)' +geometry: + meshes: + - id: housing_front + path: meshes/前側.stl + unit: mm + material: printer_white + - id: housing_back + path: meshes/後側_w1p4.stl + unit: mm + material: printer_white + - id: phone_holder + path: meshes/スマホホルダ.stl + unit: mm + material: holder_dark + - id: led_cover_bottom + path: meshes/LED基板カバー下.stl + unit: mm + material: printer_white + - id: led_cover_right + path: meshes/LED基板カバー右.stl + unit: mm + material: printer_white + - id: led_cover_left + path: meshes/LED基板カバー左.stl + unit: mm + material: printer_white + - id: phone_body + path: meshes/SH-02M.stl + unit: mm + material: phone_body_dark + - id: evaluation_board + path: meshes/照明ムラ補正ボード.stl + unit: mm + material: printer_white +materials: + printer_white: + type: blendbsdf + weight: 0.05 + components: + - type: diffuse + reflectance: + - 0.85 + - 0.85 + - 0.85 + - type: roughconductor + alpha: 0.1 + distribution: ggx + holder_dark: + type: diffuse + reflectance: + - 0.5 + - 0.5 + - 0.5 + phone_body_dark: + type: diffuse + reflectance: + - 0.05 + - 0.05 + - 0.05 +lights: +- id: led_bottom_0 + type: area + shape: rectangle + center: + - -10.0 + - -71.0 + - -66.1 + size: + - 2.8 + - 3.5 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_bottom_1 + type: area + shape: rectangle + center: + - -5.8 + - -71.0 + - -66.1 + size: + - 2.8 + - 3.5 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_bottom_2 + type: area + shape: rectangle + center: + - -1.6 + - -71.0 + - -66.1 + size: + - 2.8 + - 3.5 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_bottom_3 + type: area + shape: rectangle + center: + - 9.2 + - -71.0 + - -66.1 + size: + - 2.8 + - 3.5 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_bottom_4 + type: area + shape: rectangle + center: + - 13.4 + - -71.0 + - -66.1 + size: + - 2.8 + - 3.5 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_bottom_5 + type: area + shape: rectangle + center: + - 17.6 + - -71.0 + - -66.1 + size: + - 2.8 + - 3.5 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +sensor: + type: orthographic + position: + - 0.0 + - 0.0 + - -50.0 + target: + - 0.0 + - 0.0 + - 0.0 + up: + - 0.0 + - 1.0 + - 0.0 + ortho_scale: + - 50.0 + - 52.0 + film: + width: 512 + height: 512 + rfilter: gaussian +render: + variant: llvm_ad_rgb + integrator: path + max_depth: 16 + spp: 1024 diff --git a/configs/_tmp_fix_full_w1p4.yaml b/configs/_tmp_fix_full_w1p4.yaml new file mode 100644 index 0000000..b9b8779 --- /dev/null +++ b/configs/_tmp_fix_full_w1p4.yaml @@ -0,0 +1,412 @@ +name: full_w1p4 +description: 'TEST_12 追補: ロフト w1.4 全灯(面法線修正後)' +geometry: + meshes: + - id: housing_front + path: meshes/前側.stl + unit: mm + material: printer_white + - id: housing_back + path: meshes/後側_w1p4.stl + unit: mm + material: printer_white + - id: phone_holder + path: meshes/スマホホルダ.stl + unit: mm + material: holder_dark + - id: led_cover_bottom + path: meshes/LED基板カバー下.stl + unit: mm + material: printer_white + - id: led_cover_right + path: meshes/LED基板カバー右.stl + unit: mm + material: printer_white + - id: led_cover_left + path: meshes/LED基板カバー左.stl + unit: mm + material: printer_white + - id: phone_body + path: meshes/SH-02M.stl + unit: mm + material: phone_body_dark + - id: evaluation_board + path: meshes/照明ムラ補正ボード.stl + unit: mm + material: printer_white +materials: + printer_white: + type: blendbsdf + weight: 0.05 + components: + - type: diffuse + reflectance: + - 0.85 + - 0.85 + - 0.85 + - type: roughconductor + alpha: 0.1 + distribution: ggx + holder_dark: + type: diffuse + reflectance: + - 0.5 + - 0.5 + - 0.5 + phone_body_dark: + type: diffuse + reflectance: + - 0.05 + - 0.05 + - 0.05 +lights: +- id: led_bottom_0 + type: area + shape: rectangle + center: + - -10.0 + - -71.0 + - -66.1 + size: + - 2.8 + - 3.5 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_bottom_1 + type: area + shape: rectangle + center: + - -5.8 + - -71.0 + - -66.1 + size: + - 2.8 + - 3.5 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_bottom_2 + type: area + shape: rectangle + center: + - -1.6 + - -71.0 + - -66.1 + size: + - 2.8 + - 3.5 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_bottom_3 + type: area + shape: rectangle + center: + - 9.2 + - -71.0 + - -66.1 + size: + - 2.8 + - 3.5 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_bottom_4 + type: area + shape: rectangle + center: + - 13.4 + - -71.0 + - -66.1 + size: + - 2.8 + - 3.5 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_bottom_5 + type: area + shape: rectangle + center: + - 17.6 + - -71.0 + - -66.1 + size: + - 2.8 + - 3.5 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_right_0 + type: area + shape: rectangle + center: + - 65.9987 + - -24.9738 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_right_1 + type: area + shape: rectangle + center: + - 65.9987 + - -20.7738 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_right_2 + type: area + shape: rectangle + center: + - 65.9987 + - -16.5738 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_right_3 + type: area + shape: rectangle + center: + - 65.9987 + - -5.7738 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_right_4 + type: area + shape: rectangle + center: + - 65.9987 + - -1.5738 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_right_5 + type: area + shape: rectangle + center: + - 65.9987 + - 2.6262 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_left_0 + type: area + shape: rectangle + center: + - -66.0067 + - -32.5952 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_left_1 + type: area + shape: rectangle + center: + - -66.0067 + - -28.3952 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_left_2 + type: area + shape: rectangle + center: + - -66.0067 + - -24.1952 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_left_3 + type: area + shape: rectangle + center: + - -66.0067 + - -13.3952 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_left_4 + type: area + shape: rectangle + center: + - -66.0067 + - -9.1952 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_left_5 + type: area + shape: rectangle + center: + - -66.0067 + - -4.9952 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +sensor: + type: orthographic + position: + - 0.0 + - 0.0 + - -50.0 + target: + - 0.0 + - 0.0 + - 0.0 + up: + - 0.0 + - 1.0 + - 0.0 + ortho_scale: + - 50.0 + - 52.0 + film: + width: 512 + height: 512 + rfilter: gaussian +render: + variant: llvm_ad_rgb + integrator: path + max_depth: 16 + spp: 1024 diff --git a/configs/_tmp_fix_left_w1p4.yaml b/configs/_tmp_fix_left_w1p4.yaml new file mode 100644 index 0000000..47fedf0 --- /dev/null +++ b/configs/_tmp_fix_left_w1p4.yaml @@ -0,0 +1,196 @@ +name: left_w1p4 +description: 'TEST_12 追補: ロフト w1.4 left 単灯(面法線修正後)' +geometry: + meshes: + - id: housing_front + path: meshes/前側.stl + unit: mm + material: printer_white + - id: housing_back + path: meshes/後側_w1p4.stl + unit: mm + material: printer_white + - id: phone_holder + path: meshes/スマホホルダ.stl + unit: mm + material: holder_dark + - id: led_cover_bottom + path: meshes/LED基板カバー下.stl + unit: mm + material: printer_white + - id: led_cover_right + path: meshes/LED基板カバー右.stl + unit: mm + material: printer_white + - id: led_cover_left + path: meshes/LED基板カバー左.stl + unit: mm + material: printer_white + - id: phone_body + path: meshes/SH-02M.stl + unit: mm + material: phone_body_dark + - id: evaluation_board + path: meshes/照明ムラ補正ボード.stl + unit: mm + material: printer_white +materials: + printer_white: + type: blendbsdf + weight: 0.05 + components: + - type: diffuse + reflectance: + - 0.85 + - 0.85 + - 0.85 + - type: roughconductor + alpha: 0.1 + distribution: ggx + holder_dark: + type: diffuse + reflectance: + - 0.5 + - 0.5 + - 0.5 + phone_body_dark: + type: diffuse + reflectance: + - 0.05 + - 0.05 + - 0.05 +lights: +- id: led_left_0 + type: area + shape: rectangle + center: + - -66.0067 + - -32.5952 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_left_1 + type: area + shape: rectangle + center: + - -66.0067 + - -28.3952 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_left_2 + type: area + shape: rectangle + center: + - -66.0067 + - -24.1952 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_left_3 + type: area + shape: rectangle + center: + - -66.0067 + - -13.3952 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_left_4 + type: area + shape: rectangle + center: + - -66.0067 + - -9.1952 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_left_5 + type: area + shape: rectangle + center: + - -66.0067 + - -4.9952 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +sensor: + type: orthographic + position: + - 0.0 + - 0.0 + - -50.0 + target: + - 0.0 + - 0.0 + - 0.0 + up: + - 0.0 + - 1.0 + - 0.0 + ortho_scale: + - 50.0 + - 52.0 + film: + width: 512 + height: 512 + rfilter: gaussian +render: + variant: llvm_ad_rgb + integrator: path + max_depth: 16 + spp: 1024 diff --git a/configs/_tmp_fix_right_w1p4.yaml b/configs/_tmp_fix_right_w1p4.yaml new file mode 100644 index 0000000..148bc2b --- /dev/null +++ b/configs/_tmp_fix_right_w1p4.yaml @@ -0,0 +1,196 @@ +name: right_w1p4 +description: 'TEST_12 追補: ロフト w1.4 right 単灯(面法線修正後)' +geometry: + meshes: + - id: housing_front + path: meshes/前側.stl + unit: mm + material: printer_white + - id: housing_back + path: meshes/後側_w1p4.stl + unit: mm + material: printer_white + - id: phone_holder + path: meshes/スマホホルダ.stl + unit: mm + material: holder_dark + - id: led_cover_bottom + path: meshes/LED基板カバー下.stl + unit: mm + material: printer_white + - id: led_cover_right + path: meshes/LED基板カバー右.stl + unit: mm + material: printer_white + - id: led_cover_left + path: meshes/LED基板カバー左.stl + unit: mm + material: printer_white + - id: phone_body + path: meshes/SH-02M.stl + unit: mm + material: phone_body_dark + - id: evaluation_board + path: meshes/照明ムラ補正ボード.stl + unit: mm + material: printer_white +materials: + printer_white: + type: blendbsdf + weight: 0.05 + components: + - type: diffuse + reflectance: + - 0.85 + - 0.85 + - 0.85 + - type: roughconductor + alpha: 0.1 + distribution: ggx + holder_dark: + type: diffuse + reflectance: + - 0.5 + - 0.5 + - 0.5 + phone_body_dark: + type: diffuse + reflectance: + - 0.05 + - 0.05 + - 0.05 +lights: +- id: led_right_0 + type: area + shape: rectangle + center: + - 65.9987 + - -24.9738 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_right_1 + type: area + shape: rectangle + center: + - 65.9987 + - -20.7738 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_right_2 + type: area + shape: rectangle + center: + - 65.9987 + - -16.5738 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_right_3 + type: area + shape: rectangle + center: + - 65.9987 + - -5.7738 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_right_4 + type: area + shape: rectangle + center: + - 65.9987 + - -1.5738 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +- id: led_right_5 + type: area + shape: rectangle + center: + - 65.9987 + - 2.6262 + - -66.0243 + size: + - 3.5 + - 2.8 + direction: + - 0.0 + - 0.0 + - -1.0 + radiance: + - 2807.2469840551203 + - 2807.2469840551203 + - 2807.2469840551203 +sensor: + type: orthographic + position: + - 0.0 + - 0.0 + - -50.0 + target: + - 0.0 + - 0.0 + - 0.0 + up: + - 0.0 + - 1.0 + - 0.0 + ortho_scale: + - 50.0 + - 52.0 + film: + width: 512 + height: 512 + rfilter: gaussian +render: + variant: llvm_ad_rgb + integrator: path + max_depth: 16 + spp: 1024 diff --git a/scripts/build_singles_fix_summary.py b/scripts/build_singles_fix_summary.py index 103dca3..8c1f5a5 100644 --- a/scripts/build_singles_fix_summary.py +++ b/scripts/build_singles_fix_summary.py @@ -1,19 +1,22 @@ -"""TEST_12 相対結論再確認: 面法線修正後の単灯 3 ジョブの形指標・灯間 NCC 集計. +"""TEST_12 相対結論再確認: 面法線修正後の単灯ジョブの形指標・灯間 NCC 集計. -TEST_09 の相対結論「シミュは 3 灯ほぼ同形(灯間 NCC 0.95x)=実機の非対称相補性 -(0.85/0.61/0.41)を再現できない」を面法線修正後のデータで再検証する. +TEST_09/10 の相対結論を面法線修正後のデータで再検証する: + 1. 「シミュは 3 灯ほぼ同形(灯間 NCC 0.95x)=実機の非対称相補性を再現できない」 + 2. ロフトレバー(w1p4 で bottom のみ平ら化,left/right・灯間 NCC 不動) 単灯の形(peak/mean・top/bot・NCC 対実機)も修正前後で対比する. +raw 指標は MC ノイズ支配(単灯 spp=1024 はノイズ > 構造振幅)のため, +平滑化(median 5px + gaussian σ=4)後の値を併記し解釈は smooth を正とする. 生成するファイル: - output/singles_fix/summary.csv -- 単灯形指標(修正前後の対比付き) - output/singles_fix/pairwise_ncc.csv -- 灯間 NCC(修正前 / 修正後 / 実機) - output/_slide_panels/singles_fix_shape_roi.png -- 3 行(灯)× 3 列のパネル + output/singles_fix/summary.csv -- 単灯形指標(修正前後・w1p4 対比付き) + output/singles_fix/pairwise_ncc.csv -- 灯間 NCC(raw / smooth) + output/_slide_panels/singles_fix_shape_roi.png -- 3 行(灯)× 4 列のパネル 使い方: uv run python scripts/build_singles_fix_summary.py 前提: - - output/singles_fix/{bottom,left,right}/luminance.npy(面法線修正後) + - output/singles_fix/{bottom,left,right}{,_w1p4}/luminance.npy(面法線修正後) - output/blend_bottom/{,left_,right_}w0.05_a0.1/luminance.npy(修正前,対比用) - lightsim/luminance_maps/{bottom,left,right}_*.npy(実機単灯) """ @@ -52,6 +55,7 @@ "right": ROOT / "output" / "blend_bottom" / "right_w0.05_a0.1" / "luminance.npy", } FIX_BASE = {s: ROOT / "output" / "singles_fix" / s / "luminance.npy" for s in SIDES} +FIX_W1P4 = {s: ROOT / "output" / "singles_fix" / f"{s}_w1p4" / "luminance.npy" for s in SIDES} CELL_SHAPE = (450, 464) @@ -95,43 +99,69 @@ Returns: 終了コード(成功なら 0,入力不足なら 1). """ - for paths in (FIX_BASE, REAL, OLD_BASE): + for paths in (FIX_BASE, FIX_W1P4, REAL, OLD_BASE): for p in paths.values(): if not p.exists(): print(f"エラー: {p} が見つかりません", file=sys.stderr) return 1 - real = {s: _load_luminance(REAL[s]) for s in SIDES} - sets = { - "old": {s: extract_roi_xywh(_load_luminance(OLD_BASE[s]), SIM_ROI) for s in SIDES}, - "fix": {s: extract_roi_xywh(_load_luminance(FIX_BASE[s]), SIM_ROI) for s in SIDES}, - } - - SUMMARY_CSV.parent.mkdir(parents=True, exist_ok=True) - with SUMMARY_CSV.open("w", encoding="utf-8", newline="") as f: - writer = csv.writer(f) - writer.writerow(["side", "version", "peak_mean", "top_bot", "ncc_vs_real"]) - for s in SIDES: - for ver, maps in sets.items(): - m = _shape_metrics(maps[s], real[s]) - writer.writerow( - [s, ver, f"{m['peak_mean']:.4f}", f"{m['top_bot']:.4f}", f"{m['ncc']:.4f}"] - ) - rm = _shape_metrics(real[s], real[s]) - writer.writerow([s, "real", f"{rm['peak_mean']:.4f}", f"{rm['top_bot']:.4f}", "1.0000"]) - print(f"summary 保存: {SUMMARY_CSV}") - - # raw の NCC は MC ノイズで 0 方向へ希釈される(単灯 spp=1024 はノイズ > 構造振幅)ため, - # 平滑化(median 5px + gaussian σ=4)後の構造のみの NCC を併記する.解釈は smooth を正とする + # raw の指標・NCC は MC ノイズ支配(単灯 spp=1024 はノイズ > 構造振幅)のため, + # 平滑化(median 5px + gaussian σ=4)後の値を併記する.解釈は smooth を正とする from scipy.ndimage import gaussian_filter, median_filter def _smooth(m: np.ndarray) -> np.ndarray: return gaussian_filter(median_filter(m, size=5), sigma=4) + real = {s: _load_luminance(REAL[s]) for s in SIDES} + sets = { + "old": {s: extract_roi_xywh(_load_luminance(OLD_BASE[s]), SIM_ROI) for s in SIDES}, + "fix": {s: extract_roi_xywh(_load_luminance(FIX_BASE[s]), SIM_ROI) for s in SIDES}, + "fix_w1p4": {s: extract_roi_xywh(_load_luminance(FIX_W1P4[s]), SIM_ROI) for s in SIDES}, + } + + SUMMARY_CSV.parent.mkdir(parents=True, exist_ok=True) + with SUMMARY_CSV.open("w", encoding="utf-8", newline="") as f: + writer = csv.writer(f) + writer.writerow( + ["side", "version", "peak_mean", "peak_mean_smooth", "top_bot", "ncc_vs_real"] + ) + for s in SIDES: + for ver, maps in sets.items(): + m = _shape_metrics(maps[s], real[s]) + pm_s = _shape_metrics(_smooth(maps[s]), None)["peak_mean"] + writer.writerow( + [ + s, + ver, + f"{m['peak_mean']:.4f}", + f"{pm_s:.4f}", + f"{m['top_bot']:.4f}", + f"{m['ncc']:.4f}", + ] + ) + rm = _shape_metrics(real[s], real[s]) + rpm_s = _shape_metrics(_smooth(real[s]), None)["peak_mean"] + writer.writerow( + [ + s, + "real", + f"{rm['peak_mean']:.4f}", + f"{rpm_s:.4f}", + f"{rm['top_bot']:.4f}", + "1.0000", + ] + ) + print(f"summary 保存: {SUMMARY_CSV}") + with PAIRWISE_CSV.open("w", encoding="utf-8", newline="") as f: writer = csv.writer(f) writer.writerow(["set", "bottom_vs_left", "bottom_vs_right", "left_vs_right"]) - for label, maps in [("old", sets["old"]), ("fix", sets["fix"]), ("real", real)]: + for label, maps in [ + ("old", sets["old"]), + ("fix", sets["fix"]), + ("fix_w1p4", sets["fix_w1p4"]), + ("real", real), + ]: smoothed = {s: _smooth(m) for s, m in maps.items()} for suffix, mm in (("raw", maps), ("smooth", smoothed)): ncc = _pairwise_ncc(mm) @@ -145,9 +175,13 @@ ) print(f"pairwise 保存: {PAIRWISE_CSV}") - # パネル: 行=灯,列=修正前 / 修正後 / 実機(各セル独立 1–99% 正規化) - cols = [("修正前(スムーズ法線)", sets["old"]), ("修正後(面法線)", sets["fix"])] - fig, axes = plt.subplots(3, 3, figsize=(3 * 4.2, 3 * 4.2), constrained_layout=True) + # パネル: 行=灯,列=修正前 / 修正後基準 / 修正後 w1p4 / 実機(各セル独立 1–99% 正規化) + cols = [ + ("修正前(スムーズ法線)", sets["old"]), + ("修正後(面法線)基準", sets["fix"]), + ("修正後(面法線)w1p4", sets["fix_w1p4"]), + ] + fig, axes = plt.subplots(3, 4, figsize=(4 * 4.2, 3 * 4.2), constrained_layout=True) for r, s in enumerate(SIDES): cells = [maps[s] for _, maps in cols] + [real[s]] titles = [label for label, _ in cols] + ["実機"]