rsegm
The rsegm package provides scalable, high-performance tools for geospatial image segmentation built on top of terra, Rcpp, and modern block-wise / tiled processing strategies. It is designed for object-based image analysis (OBIA) workflows on large raster datasets, including satellite and aerial imagery. The core focus is on producing spatially coherent, integer-labeled segment rasters that integrate cleanly with downstream raster and vector analysis in R.
Key Features
- Graph-based and hybrid segmentation algorithms: Includes Fast Felzenszwalb-Huttenlocher (FH) graph-based segmentation, Hybrid FH + region-level Mean Shift segmentation, Baatz-Schäpe multi-resolution, Fast Baatz-Schäpe multi-resolution, and SEEDS.
- Large-raster support: Robust tiled processing for rasters that do not fit comfortably in memory, and seam-aware merging to avoid boundary artifacts.
- Efficient C++ backends: Computationally intensive steps implemented in Rcpp for speed and scalability.
- terra-native design: Uses
SpatRasterthroughout and produces standard GeoTIFF outputs with integer segment IDs.
Segmentation Methods
- FH graph-based segmentation: A fast, noise-robust method often used to generate superpixels or initial regions, suitable for large multi-band rasters.
- FH + mean shift hybrid segmentation: A two-stage approach combining FH over-segmentation with region-level Mean Shift refinement to merge spectrally similar regions efficiently.
- Mean Shift segmentation: A pixel-domain mean-shift filtering and clustering method that produces smooth, spectrally homogeneous segments.
- Baatz–Schäpe multiresolution segmentation: A classical OBIA algorithm that iteratively merges adjacent regions based on spectral heterogeneity and shape criteria.
- Fast Baatz–Schäpe multiresolution segmentation: An optimized variant of the Baatz–Schäpe algorithm using efficient region bookkeeping and priority-queue merging.
- SEEDS superpixel segmentation: A hierarchical, histogram-based superpixel method that starts from a regular grid and refines boundaries via local block moves.