feat: make the 2D area filter configurable via STRUCTURA_MIN_AREA - #10
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found by running the pipeline on real excavation data for the first time.
The gap
ClassicalSegmenter,SamSegmenterandCellposeSegmenterall accept amin_area.make_segmenterconstructed 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_AREA1e-4(the default)0.0025(25 cm²)0.01(100 cm²)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.examplesays that rather than just naming the variable.Changes
Settings.min_area, read fromSTRUCTURA_MIN_AREA, default unchanged at1e-4so existing behaviour is preserved.make_segmenterthreads it into all three backends.Verification
ruffclean,mypyclean on 26 files, 58 passed / 2 skipped.🤖 Generated with Claude Code