The input data used are remote sensing image data , It can be single band or multi band data .
Running environment :windows10 pycharm python3.7.7 GDAL-3.2.3-cp37-cp37m-win_amd64.whl Bag, etc .
The complete code is as follows :
Batch processing is adopted , Import and export as file paths . You only need to modify the input / output file path to calculate the desired results .
"""
This code converts the remote sensing image into a unified processing
"""
import numpy as np
from osgeo import gdal
import os
# Normalize the remote sensing image Write function
def img_normalized(inputpath,output_filepath):
gdal.UseExceptions()
ds = gdal.Open(inputpath)
band01 = ds.GetRasterBand(1)
im_width, im_height=band01.XSize, band01.YSize
dim_z = ds.RasterCount # Number of image channels
# Get full path of output file
output_image = input_image_filepath.split("/")[-1]
print("output_image:", output_image)
output_image = output_filepath + output_image
output_image