Earth Engine 推出了
非商业配额层级 ,以保护共享计算资源并确保为所有人提供可靠的性能。非商业项目默认使用 Community
层级,但您可以随时更改项目的层级。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
发送反馈
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 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
发送反馈
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可 获得了许可,并且代码示例已根据 Apache 2.0 许可 获得了许可。有关详情,请参阅 Google 开发者网站政策 。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2026-04-20。
需要向我们提供更多信息?
[[["易于理解","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"]],["最后更新时间 (UTC):2026-04-20。"],[],["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"]]