Earth Engine には、空間テクスチャを推定する特別なメソッドがいくつかあります。画像が離散値(浮動小数点数ではない)の場合、image.entropy()
を使用して近傍のエントロピーを計算できます。
コードエディタ(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');
エントロピーの計算では離散値の入力が使用されるため、entropy()
を呼び出す前に NIR 帯域は 8 ビットにスケーリングされます。カーネル内のゼロ以外の要素は近傍を指定します。
テクスチャを測定するもう 1 つの方法は、グレースケールの共起行列(GLCM)を使用する方法です。前の例の画像とカーネルを使用して、GLCM ベースのコントラストを次のように計算します。
コードエディタ(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 et al.(1973)と Conners et al.(1984) をご覧ください。
Geary の C
(Anselin 1995)などの空間関連のローカル測定値は、Earth Engine で image.neighborhoodToBands()
を使用して計算できます。前の例の画像を使用します。
コードエディタ(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");
近傍の標準偏差を使用して画像テクスチャを計算する例については、画像近傍の統計情報のページをご覧ください。