DawnC commited on
Commit
d91432d
·
verified ·
1 Parent(s): cdf1b9d

Update lighting_analyzer.py

Browse files
Files changed (1) hide show
  1. lighting_analyzer.py +7 -7
lighting_analyzer.py CHANGED
@@ -178,7 +178,7 @@ class LightingAnalyzer:
178
  horizontal_strength = np.mean(np.abs(gx))
179
  gradient_ratio = vertical_strength / max(horizontal_strength, 1e-5)
180
 
181
- # -- 亮度均勻性 --
182
  brightness_uniformity = 1 - min(1, brightness_std / max(avg_brightness, 1e-5))
183
 
184
  # -- 高效的天花板分析 --
@@ -240,9 +240,9 @@ class LightingAnalyzer:
240
  top_gradient = np.mean(np.abs(cv2.Sobel(top_edge, cv2.CV_32F, 0, 1, ksize=3)))
241
 
242
  # 標準化
243
- left_edge_density = min(1.0, left_gradient / 50)
244
- right_edge_density = min(1.0, right_gradient / 50)
245
- top_edge_density = min(1.0, top_gradient / 50)
246
 
247
  # 封閉環境通常在圖像邊緣有較強的梯度
248
  boundary_edge_score = (left_edge_density + right_edge_density + top_edge_density) / 3
@@ -370,9 +370,9 @@ class LightingAnalyzer:
370
 
371
  # 加強對特定類型光源的檢測
372
  if circular_light_count >= 1: # 即便只有一個圓形光源也很可能是室內
373
- light_contribution = weights.get("light_features", 1.2) * 2.0
374
  elif indoor_light_score > 0.3:
375
- light_contribution = weights.get("light_features", 1.2) * 1.0
376
 
377
  indoor_score += light_contribution
378
  feature_contributions["light_features"] = light_contribution
@@ -411,7 +411,7 @@ class LightingAnalyzer:
411
 
412
  # 6. 垂直/水平梯度比率
413
  gradient_contribution = 0
414
- if features["gradient_ratio"] > 2.0:
415
  combined_uniformity = (features["brightness_uniformity"] +
416
  features.get("ceiling_uniformity", 0)) / 2
417
 
 
178
  horizontal_strength = np.mean(np.abs(gx))
179
  gradient_ratio = vertical_strength / max(horizontal_strength, 1e-5)
180
 
181
+ # 亮度的均勻性(分布)
182
  brightness_uniformity = 1 - min(1, brightness_std / max(avg_brightness, 1e-5))
183
 
184
  # -- 高效的天花板分析 --
 
240
  top_gradient = np.mean(np.abs(cv2.Sobel(top_edge, cv2.CV_32F, 0, 1, ksize=3)))
241
 
242
  # 標準化
243
+ left_edge_density = min(1, left_gradient / 50)
244
+ right_edge_density = min(1, right_gradient / 50)
245
+ top_edge_density = min(1, top_gradient / 50)
246
 
247
  # 封閉環境通常在圖像邊緣有較強的梯度
248
  boundary_edge_score = (left_edge_density + right_edge_density + top_edge_density) / 3
 
370
 
371
  # 加強對特定類型光源的檢測
372
  if circular_light_count >= 1: # 即便只有一個圓形光源也很可能是室內
373
+ light_contribution = weights.get("light_features", 1.2) * 2
374
  elif indoor_light_score > 0.3:
375
+ light_contribution = weights.get("light_features", 1.2) * 1
376
 
377
  indoor_score += light_contribution
378
  feature_contributions["light_features"] = light_contribution
 
411
 
412
  # 6. 垂直/水平梯度比率
413
  gradient_contribution = 0
414
+ if features["gradient_ratio"] > 2:
415
  combined_uniformity = (features["brightness_uniformity"] +
416
  features.get("ceiling_uniformity", 0)) / 2
417