GEE 中计算纹理特征

@GEE 中计算纹理特征

//Create and rescale a grayscale image for GLCM 
var gray = dataset.expression(
      '(0.3 * NIR) + (0.59 * R) + (0.11 * G)', {
      'NIR': dataset.select('b4'),
        'R': dataset.select('b3'),
        'G': dataset.select('b2')
}).rename('gray');
var clippedGray = gray.clip(table);
// the glcmTexture size (in pixel) can be adjusted considering the spatial resolution and the object textural characteristics

// which one line   16  or  18  is correct ? 

var glcm = gray.unitScale(0, 0.30).multiply(100).toInt().glcmTexture({size: 2});



// 定义8个基本纹理值的名称
var glcmBands = ['gray_asm', 'gray_contrast', 'gray_corr', 'gray_ent', 'gray_var', 'gray_idm', 'gray_savg', 'gray_sum'];

// 为每个基本纹理值导出图像
for (var i = 0; i < glcmBands.length; i++) {
  var currentBand = glcmBands[i];
  var exportImage = glcm.select([currentBand]);

  // 导出图像到Google Drive
  Export.image.toDrive({
    image: exportImage,
    description: 'GLCM_' + currentBand,
    fileNamePrefix: 'GLCM_' + currentBand,
    region: table.geometry(),
    scale: 10,
    maxPixels: 1e10
  });
}

// 将所有导出的图像合并成一幅影像
var mergedImage = ee.ImageCollection(glcmBands.map(function (band) {
  return ee.Image('users/%%%/test/glcm/GLCM_' + band).rename(band);
})).toBands();

// 导出合并后的影像到Google Drive
Export.image.toDrive({
  image: mergedImage,
  description: 'Merged_GLCM_Image',
 
  fileNamePrefix: 'Merged_GLCM_Image',
  region: table.geometry(),
  scale: 10,
  maxPixels: 1e10
});

输出结果
在这里插入图片描述

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值