Ankündigung: Alle nicht kommerziellen Projekte, die vor dem
15. April 2025 für die Nutzung von Earth Engine registriert wurden, müssen
die Berechtigung zur nicht kommerziellen Nutzung bestätigen, um den Zugriff aufrechtzuerhalten. Wenn Sie Ihren Status nicht bis zum 26. September 2025 bestätigen, wird Ihr Zugriff möglicherweise eingeschränkt.
ee.Algorithms.Image.Segmentation.SNIC
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Superpixel-Clustering basierend auf SNIC (Simple Non-Iterative Clustering). Gibt ein Band mit Cluster-IDs und die Durchschnittswerte pro Cluster für jedes der Eingabebänder aus. Wenn das Bild „seeds“ nicht als Eingabe bereitgestellt wird, enthält die Ausgabe ein „seeds“-Band mit den generierten Seed-Positionen. Siehe: Achanta, Radhakrishna und Susstrunk, Sabine, „Superpixels and Polygons using Simple Non-Iterative Clustering“, CVPR, 2017.
| Nutzung | Ausgabe |
|---|
ee.Algorithms.Image.Segmentation.SNIC(image, size, compactness, connectivity, neighborhoodSize, seeds) | Bild |
| Argument | Typ | Details |
|---|
image | Bild | Das Eingabebild für das Clustering. |
size | Ganzzahl, Standard: 5 | Der Abstand zwischen den Superpixel-Ausgangspositionen in Pixeln. Wenn ein „Seed“-Bild bereitgestellt wird, wird kein Raster erstellt. |
compactness | Gleitkommazahl, Standardwert: 1 | Kompaktheitsfaktor. Bei größeren Werten sind die Cluster kompakter (quadratisch). Wenn Sie diesen Wert auf 0 setzen, wird die Gewichtung nach räumlicher Distanz deaktiviert. |
connectivity | Ganzzahl, Standard: 8 | Konnektivität. Entweder 4 oder 8. |
neighborhoodSize | Ganzzahl, Standard: null | Größe der Nachbarschaft von Kacheln (um Artefakte an Kachelgrenzen zu vermeiden). Der Standardwert ist 2 × Größe. |
seeds | Bild, Standardwert: null | Wenn angegeben, werden alle Pixel mit einem Wert ungleich null als Ausgangspunkte verwendet. Pixel, die sich berühren (wie durch „connectivity“ angegeben), gehören zum selben Cluster. |
Beispiele
Code-Editor (JavaScript)
// Note that the compactness and size parameters can have a significant impact
// on the result. They must be adjusted to meet image-specific characteristics
// and patterns, typically through trial. Pixel scale (map zoom level) is also
// important to consider. When exploring interactively through map tile
// visualization, the segmentation result it dependent on zoom level. If you
// need to evaluate the result at a specific scale, call .reproject() on the
// result, but do so with caution because it overrides the default scaling
// behavior that makes tile computation fast and efficient.
// Load a NAIP image for a neighborhood in Las Vegas.
var naip = ee.Image('USDA/NAIP/DOQQ/m_3611554_sw_11_1_20170613');
// Apply the SNIC algorithm to the image.
var snic = ee.Algorithms.Image.Segmentation.SNIC({
image: naip,
size: 30,
compactness: 0.1,
connectivity: 8,
});
// Display the original NAIP image as RGB.
// Lock map zoom to maintain the desired scale of the segmentation computation.
Map.setLocked(false, 18, 18);
Map.setCenter(-115.32053, 36.182016, 18);
Map.addLayer(naip, null, 'NAIP RGB');
// Display the clusters.
Map.addLayer(snic.randomVisualizer(), null, 'Clusters');
// Display the RGB cluster means.
var visParams = {
bands: ['R_mean', 'G_mean', 'B_mean'],
min: 0,
max: 255
};
Map.addLayer(snic, visParams, 'RGB cluster means');
Python einrichten
Informationen zur Python API und zur Verwendung von geemap für die interaktive Entwicklung finden Sie auf der Seite
Python-Umgebung.
import ee
import geemap.core as geemap
Colab (Python)
# Note that the compactness and size parameters can have a significant impact
# on the result. They must be adjusted to meet image-specific characteristics
# and patterns, typically through trial. Pixel scale (map zoom level) is also
# important to consider. When exploring interactively through map tile
# visualization, the segmentation result it dependent on zoom level. If you
# need to evaluate the result at a specific scale, call .reproject() on the
# result, but do so with caution because it overrides the default scaling
# behavior that makes tile computation fast and efficient.
# Load a NAIP image for a neighborhood in Las Vegas.
naip = ee.Image('USDA/NAIP/DOQQ/m_3611554_sw_11_1_20170613')
# Apply the SNIC algorithm to the image.
snic = ee.Algorithms.Image.Segmentation.SNIC(
image=naip, size=30, compactness=0.1, connectivity=8
)
# Display the original NAIP image as RGB.
m = geemap.Map()
m.set_center(-115.32053, 36.182016, 18)
m.add_layer(naip, None, 'NAIP RGB')
# Display the clusters.
m.add_layer(snic.randomVisualizer(), None, 'Clusters')
# Display the RGB cluster means.
vis_params = {'bands': ['R_mean', 'G_mean', 'B_mean'], 'min': 0, 'max': 255}
m.add_layer(snic, vis_params, 'RGB cluster means')
m
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-07-26 (UTC).
[null,null,["Zuletzt aktualisiert: 2025-07-26 (UTC)."],[],["SNIC clustering segments an image into superpixels, outputting cluster IDs and per-cluster averages for each input band. Key parameters include `size` (seed spacing), `compactness` (cluster shape), and `connectivity`. A user can provide `seeds` to define seed locations; otherwise, they are generated. The output `Image` includes cluster IDs, band averages, and optionally generated seed locations. Adjusting `size` and `compactness` is crucial for optimal results, which are also affected by pixel scale.\n"]]