形態學運算

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');

請注意,在前述範例中,核心運算子會提供核心引數。在計算過程中,會使用核心中非零元素所涵蓋的像素。迭代引數會指出要套用運算子的次數。