优化日志显示

This commit is contained in:
xinzhu.yin
2026-04-21 15:31:48 +08:00
parent 6cc3e55ebb
commit e27312d0a3
22 changed files with 684 additions and 553 deletions

View File

@@ -1,4 +1,4 @@
"""色域图Gamut绘制。
"""色域图Gamut绘制。
Step 2 重构:从 pqAutomationApp.PQAutomationApp.plot_gamut 整体搬迁,
实现与原方法完全一致;原方法仅保留为一行转发。
@@ -30,7 +30,7 @@ def plot_gamut(self, results, coverage, test_type):
UV_PIXELS_PER_U = 615.7260
UV_PIXELS_PER_V = 599.8432
# ========== 读取用户选择的参考标准 ==========
# ========== 读取用户选择的参考标准 ==========
if test_type == "screen_module":
current_ref = self.screen_gamut_ref_var.get()
elif test_type == "sdr_movie":
@@ -40,7 +40,7 @@ def plot_gamut(self, results, coverage, test_type):
else:
current_ref = "DCI-P3"
# ========== ✅✅根据参考标准重新计算覆盖率XY 空间)==========
# ========== ✅✅根据参考标准重新计算覆盖率XY 空间)==========
xy_coverage = coverage # 默认使用传入的值
uv_coverage = 0.0
@@ -67,18 +67,18 @@ def plot_gamut(self, results, coverage, test_type):
xy_points
)
else:
self.log_gui.log(f"⚠️ 未知参考标准 '{current_ref}',使用 DCI-P3")
self.log_gui.log(f"未知参考标准 '{current_ref}',使用 DCI-P3", level="error")
_, xy_coverage = pq_algorithm.calculate_gamut_coverage_DCIP3(
xy_points
)
current_ref = "DCI-P3"
self.log_gui.log(
f"XY 空间覆盖率({current_ref}: {xy_coverage:.1f}%"
)
f"XY 空间覆盖率({current_ref}: {xy_coverage:.1f}%"
, level="success")
except Exception as e:
self.log_gui.log(f"⚠️ 重新计算 XY 覆盖率失败: {str(e)}")
self.log_gui.log(f"重新计算 XY 覆盖率失败: {str(e)}", level="error")
xy_coverage = coverage # 回退到传入值
# =================================================
@@ -87,7 +87,7 @@ def plot_gamut(self, results, coverage, test_type):
img_xy = mpimg.imread(get_resource_path("assets/cie.png"))
h_xy, w_xy = img_xy.shape[:2]
self.log_gui.log(f"加载 XY 色域图: {w_xy}x{h_xy}")
self.log_gui.log(f"加载 XY 色域图: {w_xy}x{h_xy}", level="info")
self.gamut_ax_xy.imshow(img_xy, extent=[0, w_xy, h_xy, 0], aspect="equal")
self.gamut_ax_xy.set_xlim(0, w_xy)
@@ -109,7 +109,7 @@ def plot_gamut(self, results, coverage, test_type):
self.log_gui.log(
f"测量色域: R({red_x:.4f},{red_y:.4f}) "
f"G({green_x:.4f},{green_y:.4f}) B({blue_x:.4f},{blue_y:.4f})"
)
, level="info")
# ========== 绘制测量三角形 ==========
points = [
@@ -257,7 +257,7 @@ def plot_gamut(self, results, coverage, test_type):
zorder=3,
)
# ========== XY 覆盖率标注(使用重新计算的值)==========
# ========== XY 覆盖率标注(使用重新计算的值)==========
self.gamut_ax_xy.text(
w_xy * 0.85,
h_xy * 0.92,
@@ -287,17 +287,17 @@ def plot_gamut(self, results, coverage, test_type):
)
except Exception as e:
self.log_gui.log(f"XY 图绘制失败: {str(e)}")
self.log_gui.log(f"XY 图绘制失败: {str(e)}", level="error")
import traceback
self.log_gui.log(traceback.format_exc())
self.log_gui.log(traceback.format_exc(), level="error")
# ========== 右图CIE 1976 u'v' ==========
try:
img_uv = mpimg.imread(get_resource_path("assets/cie_uv.png"))
h_uv, w_uv = img_uv.shape[:2]
self.log_gui.log(f"加载 UV 色域图: {w_uv}x{h_uv}")
self.log_gui.log(f"加载 UV 色域图: {w_uv}x{h_uv}", level="info")
self.gamut_ax_uv.imshow(img_uv, extent=[0, w_uv, h_uv, 0], aspect="equal")
self.gamut_ax_uv.set_xlim(0, w_uv)
@@ -329,18 +329,18 @@ def plot_gamut(self, results, coverage, test_type):
[u, v] for u, v in [xy_to_uv(r[0], r[1]) for r in rgb_results]
]
self.log_gui.log(f"UV 坐标: {uv_coords}")
self.log_gui.log(f"UV 坐标: {uv_coords}", level="info")
# ========== ✅✅计算 u'v' 覆盖率(使用参考标准)==========
# ========== ✅✅计算 u'v' 覆盖率(使用参考标准)==========
try:
uv_coverage = pq_algorithm.calculate_uv_gamut_coverage(
uv_coords, reference=current_ref
)
self.log_gui.log(
f"UV 空间覆盖率({current_ref}: {uv_coverage:.1f}%"
)
f"UV 空间覆盖率({current_ref}: {uv_coverage:.1f}%"
, level="success")
except Exception as e:
self.log_gui.log(f"⚠️ 计算 UV 覆盖率失败: {str(e)}")
self.log_gui.log(f"计算 UV 覆盖率失败: {str(e)}", level="error")
uv_coverage = 0.0
# =================================================
@@ -491,7 +491,7 @@ def plot_gamut(self, results, coverage, test_type):
zorder=3,
)
# ========== UV 覆盖率标注(使用动态计算的值)==========
# ========== UV 覆盖率标注(使用动态计算的值)==========
self.gamut_ax_uv.text(
w_uv * 0.85,
h_uv * 0.92,
@@ -521,10 +521,10 @@ def plot_gamut(self, results, coverage, test_type):
)
except Exception as e:
self.log_gui.log(f"UV 图绘制失败: {str(e)}")
self.log_gui.log(f"UV 图绘制失败: {str(e)}", level="error")
import traceback
self.log_gui.log(traceback.format_exc())
self.log_gui.log(traceback.format_exc(), level="error")
# ========== 总标题 ==========
test_type_name = self.get_test_type_name(test_type)
@@ -535,4 +535,4 @@ def plot_gamut(self, results, coverage, test_type):
self.gamut_canvas.draw()
self.chart_notebook.select(self.gamut_chart_frame)
self.log_gui.log("色域图绘制完成")
self.log_gui.log("色域图绘制完成", level="success")