基于gee的landsat8纹理特征提取

  • Post author:
  • Post category:其他


// compute glcm texture feature
var gray = img.expression(
      '(0.3 * NIR) + (0.59 * R) + (0.11 * G)', {
      'NIR': img.select('B5'),
      'R': img.select('B4'),
      'G': img.select('B3'),
}).rename('gray');
 
var glcm = gray.unitScale(0,0.30).multiply(100).toInt().glcmTexture({size: 1,kernel:null});

print('glcm',glcm)

// Normalized
var band_glcm = glcm.select(['gray_asm','gray_contrast','gray_corr','gray_var','gray_idm',
                             'gray_savg','gray_svar','gray_sent','gray_ent']);
// calculate the min and max value of an image
var minMax = band_glcm.reduceRegion({
  reducer: ee.Reducer.minMax(),
  geometry: chongming,
  scale: 30,
  maxPixels: 1e16,
});
 
var glcm = ee.ImageCollection.fromImages(
  band_glcm.bandNames().map(function(name){
    name = ee.String(name);
    var band = band_glcm.select(name);
    return band.unitScale(ee.Number(minMax.get(name.cat('_min'))), ee.Number(minMax.get(name.cat('_max'))))
})).toBands().rename(band_glcm.bandNames());
 
Map.addLayer(glcm.select('gray_asm'),{max:1})

//add texture feature into image
var data = img.addBands(glcm)
print('data',data)



版权声明:本文为weixin_51341839原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。