Segmentation¶
Segmentation combines imagery, canopy height, and first-return density with a trained model bundle to produce individual crown polygons.
samstars.segment(...) prepares automatic prompts, generates crown proposals, and refines them into separate crown instances.
Inputs¶
For a source-raster run, provide:
- RGB or multiband imagery
- canopy height and first-return density rasters covering the same area
- a model bundle created with Training
See Data Preparation for raster alignment and band requirements.
Segment Source Rasters¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
The bundle supplies the band settings used during training.
If source bands have been reordered, pass the corresponding rgb_bands, and any nir_band or texture_band, explicitly while retaining the same channel content.
Omitted band settings reuse the bundle defaults.
Foreground Prompts¶
segment(...) and model.segment(...) reuse the bundle's fg_extra setting
when it is omitted or None. Bundles created before this setting was added
continue to use 80 extra foreground points per seed.
Pass fg_extra=0 to use only each seed as foreground, or a positive integer
to cap the additional foreground points. This works in both normal crop mode
and fast batched mode. Negative-point sampling and box prompts are unchanged;
other seeds are not automatically turned into background points.
Use a new output directory when changing the count so existing proposals are not reused. An override affects that run and does not modify the model bundle.
Outputs¶
The main output is runs/segmentation/crowns/crowns.gpkg, returned as result.crowns.
It contains one feature per predicted crown and can be opened in GIS software or read with GeoPandas.
See Downstream Analysis for its fields and uses.
With storage="persistent", the output directory also keeps prepared inputs, proposal rasters, and refinement checkpoints for inspection or resuming a run.
proposals/proposal_records.json indexes the rasters used by refinement and is managed automatically; see Advanced Workflows for its contents and reuse.
With storage="temp", intermediate files are removed after the run and final crown outputs are retained.
Overlapping tiles can produce duplicate crowns near their boundaries. See Large Raster Runs for overlap and deduplication settings.
Segment Prepared Tiles¶
A prepared tile directory contains subdirectories with img.tif, chm.tif, cost.tif, and seeds.gpkg.
Use the same image channels and cost settings as during training.
1 2 3 4 5 6 7 8 9 10 11 | |
Large Raster Runs explains how to create the tiles and choose their size. For partial reruns, intermediate rasters, and separate model files, see Advanced Workflows.