GEE学习笔记8:遥感影像归一化处理

// get one image
var image = ee.ImageCollection("LANDSAT/LC08/C01/T1_RT").first();
// calculate the min and max value of an image
var minMax = image.reduceRegion({
  reducer: ee.Reducer.minMax(),
  geometry: image.geometry(),
  scale: 30,
  maxPixels: 10e9,
  // tileScale: 16
}); 
// use unit scale to normalize the pixel values
var unitScale = ee.ImageCollection.fromImages(
  image.bandNames().map(function(name){
    name = ee.String(name);
    var band = image.select(name);
    return band.unitScale(ee.Number(minMax.get(name.cat('_min'))), ee.Number(minMax.get(name.cat('_max'))))
                // eventually multiply by 100 to get range 0-100
                //.multiply(100);
})).toBands().rename(image.bandNames());

// add the the map
Map.addLayer(image, {min: 0, max: 35000, bands: ['B4', 'B3', 'B2']}, 'original')
Map.addLayer(unitScale, {min: 0, max: 1, bands: ['B4', 'B3', 'B2']}, 'unitscaled')
Map.centerObject(unitScale)

print("image",image);
var min = image.reduceRegion({
  reducer: ee.Reducer.min(),
  geometry: image.geometry(),
  scale: 30,
  maxPixels: 1e13
});
print("min", min);
  
var max = image.reduceRegion({
    reducer: ee.Reducer.max(),
    geometry: image.geometry(),
    scale: 30,
    maxPixels: 1e13
});
print("max", max);

print("unitScale",unitScale);
var min1 = unitScale.reduceRegion({
  reducer: ee.Reducer.min(),
  geometry: unitScale.geometry(),
  scale: 30,
  maxPixels: 1e13
});
print("min", min1);
  
var max1 = unitScale.reduceRegion({
    reducer: ee.Reducer.max(),
    geometry: unitScale.geometry(),
    scale: 30,
    maxPixels: 1e13
});
print("max", max1);

GEE学习笔记8:遥感影像归一化处理_第1张图片GEE学习笔记8:遥感影像归一化处理_第2张图片GEE学习笔记8:遥感影像归一化处理_第3张图片

你可能感兴趣的:(GEE,GEE,归一化)