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:
2026-09-01 11:10:45 +09:00
co-authored by Claude Opus 5
parent 44fbe480df
commit ea254a741f
7 changed files with 116 additions and 17 deletions
@@ -9,6 +9,10 @@ from typing import Any
import numpy as np
from B04_PreProcess.B04_PreProcess_Engine_Filter_Classification import (
filter_classification,
has_classified_ground,
)
from B04_PreProcess.B04_PreProcess_Engine_Filter_CSF import filter_csf
from B04_PreProcess.B04_PreProcess_Engine_Filter_Grid import filter_grid_min_z
from B04_PreProcess.B04_PreProcess_Engine_Filter_PMF import filter_pmf
@@ -20,13 +24,29 @@ _FILTERS = {
"csf": filter_csf,
"pmf": filter_pmf,
"ransac": filter_ransac,
"classification": filter_classification,
}
# LAS에 지면분류가 실제로 들어 있을 때만 쓰는 필터 (미분류 LAS에서는 마스크가 빈다)
_CONDITIONAL_FILTERS = {"classification": has_classified_ground}
def available_filters() -> tuple[str, ...]:
return tuple(_FILTERS.keys())
def detect_extra_filters(
structured_data: dict[str, Any] | np.lib.npyio.NpzFile,
filter_keys: tuple[str, ...] | list[str],
) -> list[str]:
"""이 LAS에서만 쓸 수 있는 조건부 필터 중 아직 목록에 없는 것을 고른다."""
return [
key
for key, is_usable in _CONDITIONAL_FILTERS.items()
if key not in filter_keys and is_usable(structured_data)
]
def run_ground_filter(
filter_key: str, structured_data: dict[str, Any] | np.lib.npyio.NpzFile
) -> np.ndarray: