大疆精灵4多光谱版有六个通道,每次拍摄都会生成六张图片。图片的顺序为 0. 可见光 1. 蓝光 2. 绿光 3. 红光 4. 红边 5. 近红外。
在用其他软件进行拼接时需要对六个通道的照片分别进行拼接,而不同通道的图片仅是最后一位数字不同,因此要将相同通道的图片放到一起,易于利用软件拼接。
基于Python的os库和shutil库进行文件转移操作,代码如下
python
import shutil
import os
path = r'E:博士期间记录照片站内高光谱20210811'
files = os.listdir(path)
rgb_file = path+'\rgb'
red_file = path+'\red'
green_file = path+'\green'
blue_file = path+'\blue'
red_edge_file = path+'\red_edge'
Near_infrared_file = path+'\Near_infrared'
for f in files:
filename, suffix = os.path.splitext(f) # filename是文件名 suffix是文件后缀
if not os.path.exists(rgb_file):
os.makedirs(rgb_file)
if not os.path.exists(red_file):
os.makedirs(red_file)
if not os.path.exists(green_file):
os.makedirs(green_file)
if not os.path.exists(blue_file):
os.makedirs(blue_file)
if not os.path.exists(red_edge_file):
os.makedirs(red_edge_file)
if not os.path.exists(Near_infrared_file):
os.makedirs(Near_infrared_file)
if filename[-1] == '0':
shutil.move(os.path.join(path, f), rgb_file)
elif filename[-1] == '1':
shutil.move(os.path.join(path, f), blue_file)
elif filename[-1] == '2':
shutil.move(os.path.join(path, f), green_file)
elif filename[-1] == '3':
shutil.move(os.path.join(path, f), red_file)
elif filename[-1] == '4':
shutil.move(os.path.join(path, f), red_edge_file)
elif filename[-1] == '5':
shutil.move(os.path.join(path, f), Near_infrared_file)
结果如下



