ee.Algorithms.Image.Segmentation.KMeans
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
خوشه بندی K-Means را روی تصویر ورودی انجام می دهد. یک تصویر 1 باندی حاوی شناسه خوشه ای که هر پیکسل به آن تعلق دارد را خروجی می دهد. این الگوریتم میتواند روی یک شبکه ثابت از سلولهای غیر همپوشانی (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 یا کوچکتر محدود شود. این گزینه به صورت متقابلا انحصاری با محله سایز است. |
forceConvergence | بولی، پیش فرض: نادرست | اگر درست باشد، اگر همگرایی قبل از اعداد به دست نیاید، خطایی ایجاد می شود. |
uniqueLabels | بولی، پیش فرض: درست است | اگر درست باشد، به خوشهها شناسههای منحصربهفرد اختصاص داده میشود. در غیر این صورت، آنها در هر کاشی یا سلول شبکه تکرار می شوند. |
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003ePerforms K-Means clustering on an input image, assigning each pixel to a cluster and outputting a single-band image with cluster IDs.\u003c/p\u003e\n"],["\u003cp\u003eOffers flexibility to control clustering with parameters like \u003ccode\u003enumClusters\u003c/code\u003e, \u003ccode\u003enumIterations\u003c/code\u003e, neighborhood size, and grid size.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eneighborhoodSize\u003c/code\u003e dictates the tile overlap for cluster computation, while \u003ccode\u003egridSize\u003c/code\u003e allows independent clustering within fixed-size cells.\u003c/p\u003e\n"],["\u003cp\u003eSetting \u003ccode\u003euniqueLabels\u003c/code\u003e to true ensures distinct cluster IDs across the entire image, while false results in repeated IDs per tile or grid cell.\u003c/p\u003e\n"],["\u003cp\u003eBy default, uses tiles without overlap for clustering and assigns unique labels to clusters.\u003c/p\u003e\n"]]],["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"],null,["# ee.Algorithms.Image.Segmentation.KMeans\n\nPerforms K-Means clustering on the input image. Outputs a 1-band image containing the 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.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|\n| `ee.Algorithms.Image.Segmentation.KMeans(image, `*numClusters* `, `*numIterations* `, `*neighborhoodSize* `, `*gridSize* `, `*forceConvergence* `, `*uniqueLabels*`)` | Image |\n\n| Argument | Type | Details |\n|--------------------|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `image` | Image | The input image for clustering. |\n| `numClusters` | Integer, default: 8 | Number of clusters. |\n| `numIterations` | Integer, default: 20 | Number of iterations. |\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| `forceConvergence` | Boolean, default: false | If true, an error is thrown if convergence is not achieved before numIterations. |\n| `uniqueLabels` | Boolean, default: true | If true, clusters are assigned unique IDs. Otherwise, they repeat per tile or grid cell. |"]]