公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
形態學運算
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Earth Engine 會將形態學作業做為焦點作業,具體來說,就是 Image
類別中的 focalMax()
、focalMin()
、focalMedian()
和 focalMode()
例項方法。(這些是較通用 reduceNeighborhood()
的捷徑,可將核心中的像素輸入至任何具有數值輸出的 reducer。如要進一步瞭解如何減少鄰區數量,請參閱這個頁面。形態運算子可用於執行蝕刻、擴張、開啟和關閉等作業。舉例來說,如要執行開啟作業,請使用 focalMin()
後接 focalMax()
:
程式碼編輯器 (JavaScript)
// Load a Landsat 8 image, select the NIR band, threshold, display.
var image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318')
.select(4).gt(0.2);
Map.setCenter(-122.1899, 37.5010, 13);
Map.addLayer(image, {}, 'NIR threshold');
// Define a kernel.
var kernel = ee.Kernel.circle({radius: 1});
// Perform an erosion followed by a dilation, display.
var opened = image
.focalMin({kernel: kernel, iterations: 2})
.focalMax({kernel: kernel, iterations: 2});
Map.addLayer(opened, {}, 'opened');
請注意,在前述範例中,核心運算子會提供核心引數。在計算過程中,會使用核心中非零元素所涵蓋的像素。迭代引數會指出要套用運算子的次數。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[],["Earth Engine's `Image` class provides `focalMax()`, `focalMin()`, `focalMedian()`, and `focalMode()` for morphological operations like erosion, dilation, opening, and closing. These operations use a kernel to define the neighborhood of pixels. For example, the opening operation is achieved by applying `focalMin()` then `focalMax()`. A kernel argument defines the area for computation, and the iterations argument specifies the number of operator applications. The provided code demonstrates the opening operation on a Landsat 8 image using a circular kernel.\n"],null,[]]