fix(B04): 지면 필터의 고정 상수를 걷어내 LAS 기복·경사와 무관하게 지면을 잡는다
용화.las(기복 251.9m) 전처리에서 지면점이 0.06%까지 사라졌다. 원인은 현장 하나에
맞춰 박아둔 상수였다.
- CSF 하강 예산이 0.3185m x 150회 = 47.8m로 고정돼, 기복이 그보다 큰 산악지에서
천이 지면에 닿지 못했다. 반복 수를 collision_grid 기준 필요 하강량에서 뽑고
SURFACE_CSF_MAX_ITERATIONS로 상한만 둔다.
- CSF 6단계 수목 필터는 비교 피연산자가 뒤집혀 조건이 항상 참이었다. 셀 지면
후보 대비 높이를 보도록 순서를 바로잡는다.
- grid_min_z의 3x3 minimum_filter가 급경사에서 기준면을 경사만큼 파고들어
(중앙 1.88m > 임계 1.5m) 지면점을 떨궜다. 제거한다.
- 기준면 배열이 float32라 셀 최저점이 반올림으로 자기 기준면보다 낮아져
탈락했다. 원본 좌표와 같은 float64로 둔다.
- LAS가 지면분류(class 2)를 싣고 오면 filter_classification을 자동으로 붙인다.
미분류 LAS에서는 조용히 빠진다.
- 필터별 ground_ratio를 로그에 남기고, 하한 미만이면 WARNING을 띄운다.
지금까지는 0.06%가 나와도 "계산 완료"로만 보였다.
실측 (build_ground_masks 재계산):
용화 grid_min_z 0.52% -> 4.91% (class2 회수율 17.9% -> 93.3%)
csf 0.06% -> 1.57% (class2 회수율 1.3% -> 55.1%)
cloud_merged grid_min_z 11.60% -> 17.51%
csf 8.84% -> 10.68%
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import numpy as np
|
||||
|
||||
from B04_PreProcess.B04_PreProcess_Engine_Ground import (
|
||||
build_ground_masks,
|
||||
detect_extra_filters,
|
||||
run_ground_filter,
|
||||
summarize_masks,
|
||||
)
|
||||
@@ -22,7 +23,7 @@ from B04_PreProcess.B04_PreProcess_Engine_Pipeline import build_all_terrain_mode
|
||||
from B04_PreProcess.B04_PreProcess_Engine_Structurize import structurize_las
|
||||
from common_util.common_util_atomic import atomic_write_npz
|
||||
from common_util.common_util_json import atomic_write_json
|
||||
from config.config_system import build_surface_model_config
|
||||
from config.config_system import SURFACE_GROUND_RATIO_WARN, build_surface_model_config
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -169,10 +170,15 @@ def run_surface_analysis(
|
||||
"y_min": float(bounds[1, 0]),
|
||||
"y_max": float(bounds[1, 1]),
|
||||
}
|
||||
data = {"xyz": xyz, "bounds": bounds}
|
||||
data = {"xyz": xyz, "bounds": bounds, "classification": structured["classification"]}
|
||||
|
||||
# 2. 지면 필터 실행 — mask_{filter}.npy 영구 캐시 우선 재사용 (PLAN A-1)
|
||||
_report(40, "ground_filter", "지면 필터 적용 중")
|
||||
# LAS가 지면분류를 싣고 왔으면 필터 하나로 더 쓴다 — 미분류 LAS면 조용히 빠진다.
|
||||
extra_filters = detect_extra_filters(data, source_filters)
|
||||
if extra_filters:
|
||||
source_filters = list(source_filters) + extra_filters
|
||||
logger.info("B04 LAS 자체 지면분류 감지 — 필터 추가: %s", ", ".join(extra_filters))
|
||||
masks: dict[str, np.ndarray] = {}
|
||||
for filter_key in source_filters:
|
||||
mask_path = processed_dir / f"mask_{filter_key}.npy"
|
||||
@@ -193,6 +199,17 @@ def run_surface_analysis(
|
||||
)
|
||||
masks[filter_key] = mask
|
||||
ground_summary = summarize_masks(data, masks)
|
||||
# 지면점 비율은 필터가 조용히 실패해도 유일하게 드러나는 신호다 — 반드시 남긴다.
|
||||
for filter_key, entry in ground_summary.items():
|
||||
ratio = float(entry["ground_ratio"])
|
||||
log = logger.warning if ratio < SURFACE_GROUND_RATIO_WARN else logger.info
|
||||
log(
|
||||
"B04 지면점 %s: %d / %d (%.2f%%)",
|
||||
filter_key,
|
||||
entry["ground_point_count"],
|
||||
entry["total_point_count"],
|
||||
ratio * 100,
|
||||
)
|
||||
for filter_key, mask in masks.items():
|
||||
cache_path = processed_dir / f"ground_points_{filter_key}.npz"
|
||||
if not rebuild and cache_path.is_file():
|
||||
|
||||
Reference in New Issue
Block a user