将 pattern 切换后的等待时间设置添加到pq_config
This commit is contained in:
@@ -3,6 +3,8 @@ PQ 单步调试面板
|
||||
支持屏模组、SDR、HDR 三种测试类型的单步调试功能
|
||||
"""
|
||||
|
||||
import copy
|
||||
|
||||
import ttkbootstrap as ttk
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox
|
||||
@@ -840,8 +842,12 @@ class PQDebugPanel:
|
||||
# ==================== 构建对比数据 ====================
|
||||
comparison = {}
|
||||
|
||||
if test_item == "gamma":
|
||||
# ========== Gamma 测试:只对比 x, y, lv ==========
|
||||
if test_item in ("gamma", "eotf"):
|
||||
result_key = "gamma" if test_item == "gamma" else "eotf"
|
||||
original_gamma = self._get_gamma_from_results(result_key, index)
|
||||
new_gamma = self._calculate_gamma_at_index(
|
||||
test_type, test_item, index, new_data
|
||||
)
|
||||
comparison["x"] = (
|
||||
original_data[0],
|
||||
new_data[0],
|
||||
@@ -857,23 +863,10 @@ class PQDebugPanel:
|
||||
new_data[2],
|
||||
new_data[2] - original_data[2],
|
||||
)
|
||||
|
||||
elif test_item == "eotf":
|
||||
# ========== EOTF 测试:只对比 x, y, lv ==========
|
||||
comparison["x"] = (
|
||||
original_data[0],
|
||||
new_data[0],
|
||||
new_data[0] - original_data[0],
|
||||
)
|
||||
comparison["y"] = (
|
||||
original_data[1],
|
||||
new_data[1],
|
||||
new_data[1] - original_data[1],
|
||||
)
|
||||
comparison["lv"] = (
|
||||
original_data[2],
|
||||
new_data[2],
|
||||
new_data[2] - original_data[2],
|
||||
comparison["γ"] = (
|
||||
original_gamma,
|
||||
new_gamma,
|
||||
new_gamma - original_gamma,
|
||||
)
|
||||
|
||||
elif test_item == "accuracy":
|
||||
@@ -983,6 +976,16 @@ class PQDebugPanel:
|
||||
diff_str = f"{diff:+.2f}"
|
||||
threshold = 0.5
|
||||
|
||||
elif key == "γ":
|
||||
original_str = self._format_gamma_value(original)
|
||||
new_str = self._format_gamma_value(new)
|
||||
if original_str == "--" or new_str == "--":
|
||||
diff_str = "--"
|
||||
threshold = None
|
||||
else:
|
||||
diff_str = f"{diff:+.2f}"
|
||||
threshold = 0.05
|
||||
|
||||
else: # x, y
|
||||
# x, y 使用 4 位小数
|
||||
original_str = f"{original:.4f}"
|
||||
@@ -991,7 +994,9 @@ class PQDebugPanel:
|
||||
threshold = 0.001
|
||||
|
||||
# 判断差异
|
||||
if abs(diff) > threshold:
|
||||
if threshold is None:
|
||||
tag = "normal"
|
||||
elif abs(diff) > threshold:
|
||||
tag = "warning"
|
||||
else:
|
||||
tag = "normal"
|
||||
@@ -1114,6 +1119,79 @@ class PQDebugPanel:
|
||||
"100% Yellow",
|
||||
]
|
||||
|
||||
def _format_gamma_value(self, gamma):
|
||||
"""格式化 Gamma 值,无效时显示 --"""
|
||||
if gamma is None or gamma < 0.5 or gamma > 5.0:
|
||||
return "--"
|
||||
return f"{gamma:.2f}"
|
||||
|
||||
def _get_gamma_calc_params(self, results):
|
||||
"""获取 Gamma 计算参数(与批量测试保持一致)"""
|
||||
config_max_value = self.app.config.current_pattern.get(
|
||||
"measurement_max_value", 10
|
||||
)
|
||||
try:
|
||||
max_index_fix = int(config_max_value)
|
||||
except (ValueError, TypeError):
|
||||
max_index_fix = 10
|
||||
|
||||
actual_max_index = len(results) - 1
|
||||
if max_index_fix > actual_max_index:
|
||||
max_index_fix = actual_max_index
|
||||
|
||||
pattern_params = self.app.config.default_pattern_gray.get(
|
||||
"pattern_params", None
|
||||
)
|
||||
return max_index_fix, pattern_params
|
||||
|
||||
def _get_gamma_from_results(self, result_key, index):
|
||||
"""从原始测试结果中读取指定灰阶的 Gamma 值"""
|
||||
try:
|
||||
if result_key not in self.app.results.test_items:
|
||||
return 0.0
|
||||
|
||||
result_data = self.app.results.test_items[result_key].final_result
|
||||
if not result_data:
|
||||
return 0.0
|
||||
|
||||
gamma_list = result_data.get(result_key, [])
|
||||
if index >= len(gamma_list):
|
||||
return 0.0
|
||||
|
||||
item = gamma_list[index]
|
||||
return item[3] if len(item) > 3 else 0.0
|
||||
|
||||
except Exception as e:
|
||||
self.app.log_gui.log(f"读取 Gamma 失败: {str(e)}", level="error")
|
||||
return 0.0
|
||||
|
||||
def _calculate_gamma_at_index(self, test_type, test_item, index, new_data):
|
||||
"""用单步测量更新对应灰阶后,重新计算该点的 Gamma 值"""
|
||||
try:
|
||||
key = f"{test_type}_{test_item}"
|
||||
results = copy.deepcopy(self.original_data[key])
|
||||
|
||||
updated = list(results[index])
|
||||
updated[0] = new_data[0]
|
||||
updated[1] = new_data[1]
|
||||
updated[2] = new_data[2]
|
||||
for i in range(3, min(len(updated), len(new_data))):
|
||||
updated[i] = new_data[i]
|
||||
results[index] = updated
|
||||
|
||||
max_index_fix, pattern_params = self._get_gamma_calc_params(results)
|
||||
results_with_gamma, _ = self.app.calculate_gamma(
|
||||
results, max_index_fix, pattern_params
|
||||
)
|
||||
|
||||
if index >= len(results_with_gamma):
|
||||
return 0.0
|
||||
return results_with_gamma[index][3]
|
||||
|
||||
except Exception as e:
|
||||
self.app.log_gui.log(f"计算 Gamma 失败: {str(e)}", level="error")
|
||||
return 0.0
|
||||
|
||||
def _get_delta_e_from_results(self, test_type, color_name):
|
||||
"""从原始测试结果中读取 ΔE 值"""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user