Batch multi band images are extracted into each single band image
Running environment :windows10 pycharm python3.7.7 GDAL-3.2.3-cp37-cp37m-win_amd64.whl Bag, etc .
"""
This code will remove the background value of remote sensing image
"""
import numpy as np
from osgeo import gdal, gdalconst
import os
# Normalize the remote sensing image Write function
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," The image size is :",im_width, im_height)
dim_z = ds.RasterCount # Number of image channels
if dim_z>5:
dim_z=5 # Just before extraction 5 Band
for i in range(1, dim_z + 1):
band = ds.GetRasterBand(i)
band_array = band.ReadAsArray()
print("Image Shape:", band_array.shape)