Skip to content

feat: make the 2D area filter configurable via STRUCTURA_MIN_AREA - #10

Merged
leiverkus merged 1 commit into
mainfrom
feat/configurable-min-area
Jul 26, 2026
Merged

feat: make the 2D area filter configurable via STRUCTURA_MIN_AREA#10
leiverkus merged 1 commit into
mainfrom
feat/configurable-min-area

Conversation

@leiverkus

Copy link
Copy Markdown
Owner

Found by running the pipeline on real excavation data for the first time.

The gap

ClassicalSegmenter, SamSegmenter and CellposeSegmenter all accept a min_area. make_segmenter constructed all three without arguments, so the parameter was unreachable from configuration — tuning it meant editing the source.

That is invisible on the synthetic test fixtures and immediately blocking on a real orthophoto.

Why it matters, measured

A run over a real trench (Tiberias 2023-03-10, 33 × 24 m at 0.53 cm/px):

STRUCTURA_MIN_AREA polygons median area
1e-4 (the default) 1108 3 cm²
0.0025 (25 cm²) 107 58 cm²
0.01 (100 cm²) 29

At 0.53 cm/px the default threshold is about four pixels, so it filters nothing and the output is dominated by speckle. At 25 cm² what remains looks like stones — largest 0.14 m², which is a plausible wall stone.

The useful value scales with ground resolution and with what counts as a find, so it belongs in configuration rather than in a constant. .env.example says that rather than just naming the variable.

Changes

  • Settings.min_area, read from STRUCTURA_MIN_AREA, default unchanged at 1e-4 so existing behaviour is preserved.
  • make_segmenter threads it into all three backends.
  • A test asserting exactly that, since the failure mode is silent — the old code was not wrong, it just quietly ignored the setting.

Verification

ruff clean, mypy clean on 26 files, 58 passed / 2 skipped.

🤖 Generated with Claude Code

All three segmenters take a `min_area`, but `make_segmenter` constructed
them without arguments, so the setting was unreachable — changing it
meant editing the source. That only became visible on real data.

A first run over a real 33 x 24 m trench orthophoto (Tiberias 2023-03-10,
0.53 cm/px) produced 1108 polygons with a median area of 3 cm²: at that
resolution the 1e-4 m² default is about four pixels, so it filters
nothing. With the threshold at 25 cm² the same run yields 107 polygons,
median 58 cm², largest 0.14 m² — plausible stones.

Thread the value from Settings into every backend and document it in
.env.example, with the reasoning that the useful value scales with ground
resolution rather than being a universal constant. Default unchanged, so
existing behaviour is preserved.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@leiverkus
leiverkus merged commit 53c2173 into main Jul 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant