ee.Algorithms.Image.Segmentation.SNIC

Agrupamento de superpixels com base no SNIC (agrupamento simples não iterativo). Gera uma faixa de IDs de cluster e as médias por cluster para cada uma das faixas de entrada. Se a imagem de "seeds" não for fornecida como entrada, a saída vai incluir uma banda "seeds" com os locais de sementes gerados. Consulte: Achanta, Radhakrishna e Susstrunk, Sabine, "Superpixels and Polygons using Simple Non-Iterative Clustering", CVPR, 2017.

UsoRetorna
ee.Algorithms.Image.Segmentation.SNIC(image, size, compactness, connectivity, neighborhoodSize, seeds)Imagem
ArgumentoTipoDetalhes
imageImagemA imagem de entrada para clustering.
sizeNúmero inteiro, padrão: 5O espaçamento do local de origem do superpixel, em pixels. Se a imagem "seeds" for fornecida, nenhuma grade será produzida.
compactnessPonto flutuante, padrão: 1Fator de compacidade. Valores maiores fazem com que os clusters fiquem mais compactos (quadrados). Definir como 0 desativa a ponderação da distância espacial.
connectivityNúmero inteiro, padrão: 8Conectividade. 4 ou 8.
neighborhoodSizeNúmero inteiro, padrão: nuloTamanho da vizinhança do bloco (para evitar artefatos de limite do bloco). O padrão é 2 * tamanho.
seedsImagem, padrão: nullSe fornecidos, todos os pixels com valor diferente de zero serão usados como locais de propagação. Pixels que se tocam (conforme especificado por "conectividade") são considerados pertencentes ao mesmo cluster.

Exemplos

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');

Configuração do Python

Consulte a página Ambiente Python para informações sobre a API Python e como usar geemap para desenvolvimento interativo.

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