Janus / Guides / SNIC segmentation

Objects · any series

SNIC segmentation, step by step.

A field, a pasture or a patch of forest is many pixels with one history. SNIC cuts the image into segments of pixels whose whole series are alike, so that the next steps work on objects instead of pixels: their mean series, their polygons, a sample per segment.

01The idea

SNIC (Simple Non-Iterative Clustering, Achanta & Süsstrunk 2017) grows superpixels from seeds on a grid. Each seed takes the pixel next to it that is closest, in a distance that adds how alike the values are and how near the pixel is; a priority queue decides which segment grows next, so every pixel is visited once.

In Janus the values compared are a pixel's whole series: every date of the band shown (or every band of every date). Two pixels are alike when they had the same history, not only the same colour on one date: a pasture cleared in 2022 and a pasture cleared in 2010 end in different segments. This is how sits_segment segments a data cube in R, with the seed grids of R's snic package.

02The example

The Landsat 8/9 series of the CCDC guide: 125 dates from February 2020 to August 2026, 30 m, 1117 × 1079 pixels of Rondônia, where forest is cleared for pasture. The map shows SWIR1, NIR and red of the last date (forest green, pasture pink); the chart, the NDVI of the pin. The quality band (QA_PIXEL) removes clouds and shadows, so in the rainy season many dates have no value.

03The parameters

Tools → Spatial pattern analysis → SNIC segmentation.

The SNIC window with its parameters next to the map of Rondônia in SWIR1, NIR and red; the pin's NDVI on the chart.
SNIC's window: the seeds every 12 pixels, a pixel kept if it has a value on 10% of the dates.
ParameterDefaultWhat it does
Values comparedshownThe series on the map (the band or index of every date, the quality band applied), or every band of every date (more memory and time).
Seed spacing10Pixels between seeds: about the side of a segment.
Seed gridrectangularR snic's grids: rectangular, diamond, hexagonal or random.
Compactness0.5Larger: more regular segments; smaller: segments follow the data. In the values' units: 0.5 for an index in 0–1, about 5000 for reflectance × 10000.
Margin0.5The edges kept free of seeds, in seed spacings.
Tile size1024Segmented in tiles of this side, in parallel; segments do not cross tiles. 0: the whole area at once.
Dates without a valueinterpolateFill gaps linearly in time, or leave such pixels out.
Min dates with a value (%)50Pixels with values on fewer dates are left out.
Write the polygonsonThe segments as polygons in a GeoPackage, with their size, centre and mean of every value.

With a cloudy series, lower Min dates with a value: at 50%, almost every pixel of this series is left out and only 11 segments are made; at 10%, 8277.

04Running it

Run on the whole image: 1.2 million pixels of 125 dates in 8 seconds, in tiles on every core.

The Tasks panel: SNIC segmentation over the whole image, done in 8 seconds.
Tasks: the run and its time.

A run makes three things: the segments (a map of their numbers), each segment's mean series (opened as a new layer) and their polygons (opened as a vector layer).

05The segments

The whole image divided into 8277 segments, a colour each; the Layers panel lists the polygons, the mean series and the segments.
8277 segments, a colour each (the colours repeat: they only tell neighbours apart).

Zoomed in on the clearing of the pin, the polygons over the image: the segments follow the fields' edges and the forest's, and a clearing is a segment of its own.

The segments' polygons drawn over the Landsat image at 3 screen points per pixel: their outlines follow fields, pastures and the forest's edge.
The polygons over the image: one outline a segment.

Each polygon carries n_pixels, its centre and the mean of every value compared, so the GeoPackage opens in QGIS as it is. In Janus, hover a polygon with Alt held for its attributes, or Alt + click it to make it the ROI.

06Their mean series

The mean series is a layer like any other: each pixel has its segment's mean NDVI of every date, gaps filled. The map is the image as objects; the chart, the pin's segment: one smooth curve where the pixel had scattered values, with the clearing of 2022 plain.

The segments' mean NDVI of the last date with the polygons over it; the chart shows the mean series of the pin's segment.
The segments' mean NDVI, the last date: forest dark green, pasture brown.
The chart: the mean NDVI of the pin's segment, high until 2022, then low with the seasons of a pasture.
The pin's segment: forest until 2022, then pasture.

07What next

  • Run the tools on objects: make the mean series' layer active and run CCDC, LandTrendr or BFAST on it: a break a segment, with less noise than a pixel.
  • Interpret by object: right click the polygons → Interpret..., one segment after the other, as TimeSync does.
  • Classify: the polygons as samples of the deep learning guide, or Extract series for R or Python.
  • Script it: zeit.snic in Python.

08References

  • Achanta, R., Süsstrunk, S. (2017). Superpixels and polygons using simple non-iterative clustering. IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 4895–4904.
  • Simoes, R., Camara, G., Queiroz, G., Souza, F., Andrade, P. R., Santos, L., Carvalho, A., Ferreira, K. (2021). Satellite image time series analysis for big Earth observation data. Remote Sensing, 13(13), 2428. (sits, sits_segment)
  • Zeit: the library behind the tools of Janus.