Motivation
Object-based image analysis (OBIA) is a standard workflow in land cover mapping and remote sensing. The typical pipeline is: segment the image into regions, compute statistics per region, then classify regions. xarray-spatial has nothing for the segmentation step, so users can't do OBIA without leaving the library.
Scope
Segmentation algorithms:
- Superpixel segmentation (SLIC or similar) that works on multi-band rasters
- Watershed segmentation from gradient/edge images
- Region growing from user-supplied seed points
Segment-level statistics:
- Mean, std, min, max of spectral values per segment
- Shape metrics per segment: area, perimeter, compactness, elongation
- Output as a segment attribute table (pandas/xarray Dataset)
Implementation notes
- Output should be an integer-labeled raster, consistent with what
regions() already produces. This lets existing zonal stats functions work on the segments directly.
- The hard part is dask compatibility. Segmentation is inherently a global operation since segments can span chunk boundaries. Realistic options:
- Run segmentation on the full array (fine for moderate sizes, and what most users actually do)
- Two-pass approach: segment each chunk independently, then merge segments that touch at boundaries
- Keep segmentation as a non-dask operation, but make the downstream stat extraction dask-friendly
- For GPU support, SLIC and watershed both have known CUDA implementations. Region growing is trickier on GPU but possible with iterative kernel launches.
- Multi-band input means the segmentation functions need to accept a 3D (band, y, x) DataArray or a list of 2D DataArrays.
Motivation
Object-based image analysis (OBIA) is a standard workflow in land cover mapping and remote sensing. The typical pipeline is: segment the image into regions, compute statistics per region, then classify regions. xarray-spatial has nothing for the segmentation step, so users can't do OBIA without leaving the library.
Scope
Segmentation algorithms:
Segment-level statistics:
Implementation notes
regions()already produces. This lets existing zonal stats functions work on the segments directly.