Earth Engine 提供了多种用于估算空间纹理的特殊方法。当图片是离散值(而非浮点值)时,您可以使用 image.entropy()
计算邻域中的熵:
// Load a high-resolution NAIP image. var image = ee.Image('USDA/NAIP/DOQQ/m_3712213_sw_10_1_20140613'); // Zoom to San Francisco, display. Map.setCenter(-122.466123, 37.769833, 17); Map.addLayer(image, {max: 255}, 'image'); // Get the NIR band. var nir = image.select('N'); // Define a neighborhood with a kernel. var square = ee.Kernel.square({radius: 4}); // Compute entropy and display. var entropy = nir.entropy(square); Map.addLayer(entropy, {min: 1, max: 5, palette: ['0000CC', 'CC0000']}, 'entropy');
请注意,NIR 波段会在调用 entropy()
之前缩放为 8 位,因为熵计算需要离散值输入。内核中的非零元素指定了邻域。
测量纹理的另一种方法是使用灰度级共现矩阵 (GLCM)。使用上例中的图片和核,按如下方式计算基于 GLCM 的对比度:
// Compute the gray-level co-occurrence matrix (GLCM), get contrast. var glcm = nir.glcmTexture({size: 4}); var contrast = glcm.select('N_contrast'); Map.addLayer(contrast, {min: 0, max: 1500, palette: ['0000CC', 'CC0000']}, 'contrast');
image.glcm()
会输出许多纹理测量值。如需查看输出的完整参考文档,请参阅 Haralick 等人 (1973) 和 Conners 等人 (1984)。
您可以在 Earth Engine 中使用 image.neighborhoodToBands()
计算 Geary 的 C
(Anselin 1995) 等空间关联的局部测量值。使用上例中的图片:
// Create a list of weights for a 9x9 kernel. var row = [1, 1, 1, 1, 1, 1, 1, 1, 1]; // The center of the kernel is zero. var centerRow = [1, 1, 1, 1, 0, 1, 1, 1, 1]; // Assemble a list of lists: the 9x9 kernel weights as a 2-D matrix. var rows = [row, row, row, row, centerRow, row, row, row, row]; // Create the kernel from the weights. // Non-zero weights represent the spatial neighborhood. var kernel = ee.Kernel.fixed(9, 9, rows, -4, -4, false); // Convert the neighborhood into multiple bands. var neighs = nir.neighborhoodToBands(kernel); // Compute local Geary's C, a measure of spatial association. var gearys = nir.subtract(neighs).pow(2).reduce(ee.Reducer.sum()) .divide(Math.pow(9, 2)); Map.addLayer(gearys, {min: 20, max: 2500, palette: ['0000CC', 'CC0000']}, "Geary's C");
如需查看使用邻域标准差计算图片纹理的示例,请参阅“图片邻域的统计信息”页面。