批量将多波段图像提取为各个单波段图像
运行环境:windows10 pycharm python3.7.7 GDAL-3.2.3-cp37-cp37m-win_amd64.whl包等。
2.实现代码"""
此段代码将遥感图像背景值去除处理
"""
import numpy as np
from osgeo import gdal, gdalconst
import os
#将遥感影像归一化处理 写成函数
def GetEnvolopePoint(inputpath,output_filepath):
gdal.UseExceptions()
ds = gdal.Open(inputpath)
band01 = ds.GetRasterBand(1)
im_width, im_height = band01.XSize, band01.YSize
print(inputpath,"影像大小为:",im_width, im_height)
dim_z = ds.RasterCount #图像通道数
if dim_z>5:
dim_z=5 #只提取前5个波段
for i in range(1, dim_z + 1):
band = ds.GetRasterBand(i)
band_array = band.ReadAsArray()
print("Image Shape:", band_array.shape)



