def get_spectral_data(img_id, h, w, bands=['A', 'M', 'P']):
res = []
for waveband in bands:
image_path = '{}/{}_{}.tif'.format(sixteen_band_path, img_id, waveband)
image = tiff.imread(image_path)
if len(image.shape) == 2: # for panchromatic band
image.shape = (1,) + image.shape
image = image.transpose((1, 2, 0))
image = cv2.resize(image, (w, h), interpolation=cv2.INTER_LANCZOS4)
if len(image.shape) == 2: # for panchromatic band
image.shape += (1,)
res.append(image)
image = np.concatenate(res, axis=2)
image = image.astype(np.float32)
return image
utils.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录