公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Algorithms.Image.Segmentation.GMeans
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
对输入图片执行 G-Means 聚类。迭代应用 k-means,然后进行正态性检验,以自动确定要使用的聚类数量。输出包含一个“clusters”波段,其中包含每个像素所属的聚类的整数 ID。该算法可以处理不重叠的固定网格单元(gridSize,可以小于图块),也可以处理重叠的图块(neighborhoodSize)。默认情况下,使用不重叠的图块。一个单元格或图块中的集群与另一个单元格或图块中的集群无关。任何跨越单元格或图块边界的聚类都可能在两个半部分中收到两个不同的标签。任何带有部分遮罩的输入像素在输出中都会被完全遮盖。此算法预计仅在动态范围较窄(即字节或短整数)的图片上表现良好。
请参阅:G. Hamerly 和 C. Elkan。“Learning the k in k-means”(学习 k-means 中的 k)。NIPS,2003 年。
用法 | 返回 |
---|
ee.Algorithms.Image.Segmentation.GMeans(image, numIterations, pValue, neighborhoodSize, gridSize, uniqueLabels) | 图片 |
参数 | 类型 | 详细信息 |
---|
image | 图片 | 用于聚类的输入图片。 |
numIterations | 整数,默认值:10 | 迭代次数。默认值为 10。 |
pValue | 浮点数,默认值:50 | 正态性检验的显著性水平。 |
neighborhoodSize | 整数,默认值:0 | 邻域大小。计算聚类时,每个图块的扩展量(重叠)。此选项与 gridSize 互斥。 |
gridSize | 整数,默认值:null | 网格单元格大小。如果大于 0,则 kMeans 将独立运行于此大小的单元格上。这会限制任何聚类的大小,使其不大于 gridSize。此选项与 neighborhoodSize 互斥。 |
uniqueLabels | 布尔值,默认值:true | 如果值为 true,则为集群分配唯一 ID。否则,它们会按平铺或网格单元格重复。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[[["\u003cp\u003eThe GMeans algorithm automatically determines the optimal number of clusters for image segmentation using iterative k-means and a normality test.\u003c/p\u003e\n"],["\u003cp\u003eIt outputs an image with a 'clusters' band, assigning each pixel an integer ID corresponding to its cluster.\u003c/p\u003e\n"],["\u003cp\u003eUsers can control segmentation granularity through \u003ccode\u003egridSize\u003c/code\u003e for non-overlapping cells or \u003ccode\u003eneighborhoodSize\u003c/code\u003e for overlapping tiles.\u003c/p\u003e\n"],["\u003cp\u003eClusters are independent within each cell or tile, potentially leading to different labels for the same cluster across boundaries.\u003c/p\u003e\n"],["\u003cp\u003eThe algorithm is best suited for images with a narrow dynamic range, like those with byte or short data types.\u003c/p\u003e\n"]]],["The G-Means algorithm performs image clustering by iteratively applying k-means and a normality test to determine the optimal number of clusters. It outputs an image with a 'clusters' band, assigning each pixel to a cluster. It can operate on a fixed grid (gridSize) or tiles with overlap (neighborhoodSize), with default being tiles without overlap. Input images should have a narrow dynamic range and pixels with partial mask will be fully masked in the output. Clusters can be assigned unique ID's or repeat per tile.\n"],null,["# ee.Algorithms.Image.Segmentation.GMeans\n\nPerforms G-Means clustering on the input image. Iteratively applies k-means followed by a normality test to automatically determine the number of clusters to use. The output contains a 'clusters' band containing the integer ID of the cluster that each pixel belongs to. The algorithm can work either on a fixed grid of non-overlapping cells (gridSize, which can be smaller than a tile) or on tiles with overlap (neighborhoodSize). The default is to use tiles with no overlap. Clusters in one cell or tile are unrelated to clusters in another. Any cluster that spans a cell or tile boundary may receive two different labels in the two halves. Any input pixels with partial masks are fully masked in the output. This algorithm is only expected to perform well for images with a narrow dynamic range (i.e., bytes or shorts).\n\n\u003cbr /\u003e\n\nSee: G. Hamerly and C. Elkan. 'Learning the k in k-means'. NIPS, 2003.\n\n| Usage | Returns |\n|-------------------------------------------------------------------------------------------------------------------------------------------|---------|\n| `ee.Algorithms.Image.Segmentation.GMeans(image, `*numIterations* `, `*pValue* `, `*neighborhoodSize* `, `*gridSize* `, `*uniqueLabels*`)` | Image |\n\n| Argument | Type | Details |\n|--------------------|------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `image` | Image | The input image for clustering. |\n| `numIterations` | Integer, default: 10 | Number of iterations. Default 10. |\n| `pValue` | Float, default: 50 | Significance level for normality test. |\n| `neighborhoodSize` | Integer, default: 0 | Neighborhood size. The amount to extend each tile (overlap) when computing the clusters. This option is mutually exclusive with gridSize. |\n| `gridSize` | Integer, default: null | Grid cell-size. If greater than 0, kMeans will be run independently on cells of this size. This has the effect of limiting the size of any cluster to be gridSize or smaller. This option is mutually exclusive with neighborhoodSize. |\n| `uniqueLabels` | Boolean, default: true | If true, clusters are assigned unique IDs. Otherwise, they repeat per tile or grid cell. |"]]