我的图像为5通道的tiff文件,RBG分别是第1,2,3波段,想要使用这三个波段作为底层影像观测输出结果,因此首先提取它们:
这里仅列举单个图像的
import tifffile
import numpy as np
from PIL import Image
# 读取多波段图像
image = tifffile.imread("E:/Nomal data/training_data_v3/compressed/images/17784962.tiff")
# 提取RGB三层
red_channel = image[:, :, 0] # 假设第一个波段为红色通道
green_channel = image[:, :, 1] # 假设第二个波段为绿色通道
blue_channel = image[:, :, 2] # 假设第三个波段为蓝色通道
# 创建RGB图像
rgb_image = np.stack([red_channel, green_channel, blue_channel], axis=-1)
# 保存RGB图像
tifffile.imwrite("E:/picture/rgb.tif", rgb_image)