ee.Algorithms.Image.Segmentation.SNIC

SNIC (Simple Non-Iterative Clustering) 기반 슈퍼픽셀 클러스터링 클러스터 ID와 각 입력 밴드의 클러스터별 평균을 출력합니다. '시드' 이미지가 입력으로 제공되지 않으면 생성된 시드 위치가 포함된 '시드' 밴드가 출력에 포함됩니다. Achanta, Radhakrishna, Susstrunk, Sabine, 'Superpixels and Polygons using Simple Non-Iterative Clustering', CVPR, 2017 참고

사용반환 값
ee.Algorithms.Image.Segmentation.SNIC(image, size, compactness, connectivity, neighborhoodSize, seeds)이미지
인수유형세부정보
image이미지클러스터링할 입력 이미지입니다.
size정수, 기본값: 5슈퍼픽셀 시드 위치 간격(픽셀)입니다. '시드' 이미지가 제공되면 그리드가 생성되지 않습니다.
compactness부동 소수점 수, 기본값: 1간결성 요소입니다. 값이 클수록 클러스터가 더 콤팩트해집니다 (사각형). 이 값을 0으로 설정하면 공간 거리 가중치가 사용 중지됩니다.
connectivity정수, 기본값: 8연결을 탭합니다. 4 또는 8입니다.
neighborhoodSize정수, 기본값: null타일 인접 크기 (타일 경계 아티팩트 방지) 기본값은 2 * 크기입니다.
seeds이미지, 기본값: null제공된 경우 0이 아닌 값의 픽셀이 시드 위치로 사용됩니다. '연결성'에 따라 서로 닿는 픽셀은 동일한 클러스터에 속하는 것으로 간주됩니다.

코드 편집기 (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 설정

Python API 및 geemap를 사용한 대화형 개발에 관한 자세한 내용은 Python 환경 페이지를 참고하세요.

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