Page Summary
-
The G-Means algorithm performs clustering on an input image by iteratively applying k-means and a normality test to automatically determine the number of clusters.
-
The output image includes a 'clusters' band indicating the cluster ID for each pixel.
-
The algorithm can operate on a fixed grid or overlapping tiles, with the default being non-overlapping tiles.
-
Clusters are independent across cells or tiles, meaning a cluster spanning a boundary may receive different labels on each side.
-
This algorithm is best suited for images with a narrow dynamic range (e.g., bytes or shorts).
See: G. Hamerly and C. Elkan. 'Learning the k in k-means'. NIPS, 2003.
| Usage | Returns |
|---|---|
ee.Algorithms.Image.Segmentation.GMeans(image, numIterations
, pValue
, neighborhoodSize
, gridSize
, uniqueLabels
)
|
Image |
| Argument | Type | Details |
|---|---|---|
image
|
Image | The input image for clustering. |
numIterations
|
Integer, default: 10 | Number of iterations. Default 10. |
pValue
|
Float, default: 50 | Significance level for normality test. |
neighborhoodSize
|
Integer, default: 0 | Neighborhood size. The amount to extend each tile (overlap) when computing the clusters. This option is mutually exclusive with gridSize. |
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. |
uniqueLabels
|
Boolean, default: true | If true, clusters are assigned unique IDs. Otherwise, they repeat per tile or grid cell. |

