Earth Engine 推出了
非商业配额层级,以保护共享计算资源并确保为所有人提供可靠的性能。非商业项目默认使用 Community
层级,但您可以随时更改项目的层级。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
ee.Algorithms.Image.Segmentation.KMeans
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
对输入图片执行 K-Means 聚类。输出一个单波段图片,其中包含每个像素所属的聚类的 ID。该算法可以处理固定网格的非重叠单元格(gridSize,可以小于图块),也可以处理重叠图块 (neighborhoodSize)。默认情况下,该算法使用不重叠的图块。
一个单元格或图块中的聚类与其他单元格或图块中的聚类无关。任何跨越单元格或图块边界的聚类都可能在两个部分中收到两个不同的标签。任何带有部分掩码的输入像素在输出中都会被完全掩盖。
| 用法 | 返回 |
|---|
ee.Algorithms.Image.Segmentation.KMeans(image, numClusters, numIterations, neighborhoodSize, gridSize, forceConvergence, uniqueLabels) | 图片 |
| 参数 | 类型 | 详细信息 |
|---|
image | 图片 | 用于聚类的输入图片。 |
numClusters | 整数,默认值:8 | 聚类数。 |
numIterations | 整数,默认值:20 | 迭代次数。 |
neighborhoodSize | 整数,默认值:0 | 邻域大小。计算聚类时要扩展每个图块(重叠)的量。此选项与 gridSize 互斥。 |
gridSize | 整数,默认值:null | 网格单元格大小。如果大于 0,则 kMeans 将在此大小的单元格上独立运行。这样做的效果是将任何聚类的大小限制为 gridSize 或更小。此选项与 neighborhoodSize 互斥。 |
forceConvergence | 布尔值,默认值:false | 如果为 true,则在 numIterations 之前未实现收敛时会抛出错误。 |
uniqueLabels | 布尔值,默认值:true | 如果为 true,则会为聚类分配唯一 ID。否则,它们会按图块或网格单元格重复。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2026-04-20。
[null,null,["最后更新时间 (UTC):2026-04-20。"],[],["K-Means clustering is applied to an input image, generating a single-band output image where each pixel is assigned a cluster ID. Clustering can occur within a fixed grid (`gridSize`) or within overlapping tiles (`neighborhoodSize`). By default, tiles have no overlap. Clusters are independent per cell/tile, potentially resulting in different labels for clusters crossing boundaries. Parameters include the number of clusters and iterations. Convergence can be enforced and the ID labels be unique or repeat depending on the specified parameter.\n"]]