ee.Algorithms.Image.Segmentation.SNIC

Agrupación de superpíxeles basada en SNIC (agrupación simple no iterativa). Muestra una banda de IDs de clústeres y los promedios por clúster para cada una de las bandas de entrada. Si la imagen 'seeds' no se proporciona como entrada, la salida incluirá una banda 'seeds' que contiene las ubicaciones de semillas generadas.

Consulta: Achanta, Radhakrishna y Susstrunk, Sabine, "Superpixels and Polygons using Simple Non-Iterative Clustering", CVPR, 2017.

UsoMuestra
ee.Algorithms.Image.Segmentation.SNIC(image, size, compactness, connectivity, neighborhoodSize, seeds)Imagen
ArgumentoTipoDetalles
imageImagenLa imagen de entrada para la agrupación.
sizeNúmero entero, valor predeterminado: 5El espaciado de la ubicación de la semilla de superpíxeles, en píxeles. Si se proporciona la imagen "seeds", no se produce ninguna cuadrícula.
compactnessFlotante, valor predeterminado: 1Factor de compacidad. Los valores más grandes hacen que los clústeres sean más compactos (cuadrados). Si se establece en 0, se inhabilita la ponderación de la distancia espacial.
connectivityNúmero entero, valor predeterminado: 8Conectividad. 4 u 8.
neighborhoodSizeNúmero entero, valor predeterminado: nuloTamaño del vecindario de mosaicos (para evitar artefactos de límite de mosaicos). El valor predeterminado es 2 * tamaño.
seedsImagen, valor predeterminado: nuloSi se proporciona, los píxeles con valores distintos de cero se usan como ubicaciones de semillas. Se considera que los píxeles que se tocan (como se especifica en "connectivity") pertenecen al mismo clúster.

Ejemplos

Editor de código (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');

Configuración de Python

Consulta la página Entorno de Python para obtener información sobre la API de Python y el uso de geemap para el desarrollo interactivo.

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