公告 :凡是在
2025 年 4 月 15 日前 註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格 ,才能繼續存取。如未在 2025 年 9 月 26 日前完成驗證,存取權可能會暫停。
提供意見
ee.Algorithms.Image.Segmentation.SNIC
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
以 SNIC (簡單非疊代叢集) 為基礎的超像素叢集。針對每個輸入頻帶,輸出叢集 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 * size。 seeds
圖片 (預設值:null) 如果提供,系統會將任何非零值的像素做為初始位置。如果像素觸及 (如「連線」所指定),則視為屬於同一個叢集。
範例
程式碼編輯器 (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 環境 頁面,瞭解 Python API 和如何使用 geemap
進行互動式開發。
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
提供意見
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權 ,程式碼範例則為阿帕契 2.0 授權 。詳情請參閱《Google Developers 網站政策 》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
想進一步說明嗎?
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-26 (世界標準時間)。"],[],["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"]]