公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
ee.Algorithms.Image.Segmentation.GMeans
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
對輸入圖片執行 G-Means 分群。反覆套用 k-means,然後進行常態性檢定,自動判斷要使用的叢集數量。輸出內容包含「clusters」頻帶,其中含有每個像素所屬叢集的整數 ID。演算法可處理不重疊的固定儲存格格線 (gridSize,可小於圖塊),或處理重疊的圖塊 (neighborhoodSize)。預設值為使用不重疊的圖塊。一個儲存格或圖塊中的叢集與另一個儲存格或圖塊中的叢集無關。如果叢集跨越儲存格或圖塊邊界,兩半可能會收到兩個不同的標籤。輸出內容會完全遮蓋任何含有部分遮罩的輸入像素。這項演算法只適用於動態範圍較窄的圖片 (即位元組或短片)。
請參閱:G. Hamerly 和 C. Elkan。「學習 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。否則會依圖塊或格線儲存格重複顯示。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間: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. |"]]