公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
纹理
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Earth Engine 提供了多种用于估算空间纹理的特殊方法。当图片是离散值(而非浮点值)时,您可以使用 image.entropy()
计算邻域中的熵:
Code Editor (JavaScript)
// 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 的对比度:
Code Editor (JavaScript)
// 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) 等空间关联的局部测量值。使用上例中的图片:
Code Editor (JavaScript)
// 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");
如需查看使用邻域标准差计算图片纹理的示例,请参阅“图片邻域的统计信息”页面。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eEarth Engine provides various methods for estimating spatial texture, including entropy, GLCM, and Geary's C.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eimage.entropy()\u003c/code\u003e method calculates entropy in a neighborhood for discrete-valued images.\u003c/p\u003e\n"],["\u003cp\u003eGray-level co-occurrence matrix (GLCM) texture measures, such as contrast, can be computed using \u003ccode\u003eimage.glcmTexture()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eSpatial association, like Geary's C, can be calculated by using \u003ccode\u003eimage.neighborhoodToBands()\u003c/code\u003e to analyze neighborhood relationships.\u003c/p\u003e\n"],["\u003cp\u003eNeighborhood statistics, including standard deviation, offer another approach to texture analysis, as demonstrated on the Statistics of Image Neighborhoods page.\u003c/p\u003e\n"]]],["Earth Engine provides tools for estimating spatial texture. `image.entropy()` calculates entropy in a discrete-valued image neighborhood, using a kernel to define that neighborhood. `image.glcmTexture()` computes gray-level co-occurrence matrix (GLCM) texture measures like contrast. `image.neighborhoodToBands()` enables the computation of spatial associations like Geary's C, using a specified kernel and neighborhood weights. Standard deviation can also be used as explained in the earth-engine documentation.\n"],null,["# Texture\n\nEarth Engine has several special methods for estimating spatial texture. When\nthe image is discrete valued (not floating point), you can use `image.entropy()`\nto compute the\n[entropy](http://en.wikipedia.org/wiki/Entropy_(information_theory))\nin a neighborhood:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load a high-resolution NAIP image.\nvar image = ee.Image('USDA/NAIP/DOQQ/m_3712213_sw_10_1_20140613');\n\n// Zoom to San Francisco, display.\nMap.setCenter(-122.466123, 37.769833, 17);\nMap.addLayer(image, {max: 255}, 'image');\n\n// Get the NIR band.\nvar nir = image.select('N');\n\n// Define a neighborhood with a kernel.\nvar square = ee.Kernel.square({radius: 4});\n\n// Compute entropy and display.\nvar entropy = nir.entropy(square);\nMap.addLayer(entropy,\n {min: 1, max: 5, palette: ['0000CC', 'CC0000']},\n 'entropy');\n```\n\nNote that the NIR band is scaled to 8-bits prior to calling `entropy()`\nsince the entropy computation takes discrete valued inputs. The non-zero elements in the\nkernel specify the neighborhood.\n\nAnother way to measure texture is with a gray-level co-occurrence matrix (GLCM). Using\nthe image and kernel from the previous example, compute the GLCM-based contrast as follows:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Compute the gray-level co-occurrence matrix (GLCM), get contrast.\nvar glcm = nir.glcmTexture({size: 4});\nvar contrast = glcm.select('N_contrast');\nMap.addLayer(contrast,\n {min: 0, max: 1500, palette: ['0000CC', 'CC0000']},\n 'contrast');\n```\n\nMany measures of texture are output by `image.glcm()`. For a complete\nreference on the outputs, see\n[Haralick et al.\n(1973)](http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4309314&tag=1) and\n[Conners et al.\n(1984)](http://www.sciencedirect.com/science/article/pii/0734189X8490197X).\n\nLocal measures of spatial association such as Geary's C\n[(Anselin 1995)](http://onlinelibrary.wiley.com/doi/10.1111/j.1538-4632.1995.tb00338.x/abstract) can be computed in Earth Engine using\n`image.neighborhoodToBands()`. Using the image from the previous example:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Create a list of weights for a 9x9 kernel.\nvar row = [1, 1, 1, 1, 1, 1, 1, 1, 1];\n// The center of the kernel is zero.\nvar centerRow = [1, 1, 1, 1, 0, 1, 1, 1, 1];\n// Assemble a list of lists: the 9x9 kernel weights as a 2-D matrix.\nvar rows = [row, row, row, row, centerRow, row, row, row, row];\n// Create the kernel from the weights.\n// Non-zero weights represent the spatial neighborhood.\nvar kernel = ee.Kernel.fixed(9, 9, rows, -4, -4, false);\n\n// Convert the neighborhood into multiple bands.\nvar neighs = nir.neighborhoodToBands(kernel);\n\n// Compute local Geary's C, a measure of spatial association.\nvar gearys = nir.subtract(neighs).pow(2).reduce(ee.Reducer.sum())\n .divide(Math.pow(9, 2));\nMap.addLayer(gearys,\n {min: 20, max: 2500, palette: ['0000CC', 'CC0000']},\n \"Geary's C\");\n```\n\nFor an example of using neighborhood standard deviation to compute image texture, see the\n[Statistics of Image Neighborhoods page](/earth-engine/guides/reducers_reduce_neighborhood)."]]