Google Earth Engine---形态操作

形态操作Morphological Operations

GEE改进了形态操作成为焦点操作(focal operations),具体为Image类的focal_max(),focal_min(),focal_median(),and focal_mode()实例方法。(这些是更加通用的reduceneighborhood()方法的快捷版,reduceneighborhood()可以使kernel里的每一个像素进入到任何reducer得到一个数字输出。参考该页获取更多在reducing neighborhoods方面的信息。)形态操作在执行侵蚀erosion、膨胀dilation、打开opending和关闭closing等方面是有用的。例如,执行一个opending操作,使用focal_min()跟随一个focal_max():

// Load a Landsat 8 image, select the NIR band, threshold, display.
var image = ee.Image('LANDSAT/LC08/C01/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
             .focal_min({kernel: kernel, iterations: 2})
             .focal_max({kernel: kernel, iterations: 2});
Map.addLayer(opened, {}, 'opened');
    

注意在前面的例子里,提供了一个kernel参数给形态操作。kernel非零元素对应的像素值被用来计算。迭代参数表明应用到操作的次数。

你可能感兴趣的:(Google,Earth,Engine)