首先将fds文件转化为raw文件,然后将raw文件转化为png格式文件。
下面是fds转化为raw的部分matlab代码,完整的需要下载哦。
% 将fds转化为raw
clc;clear all;
filenames=dir('fds/*.fds');
filesnames={
filenames.name};
files = [];
len_names=length(filesnames);
k=1;
for i = 1:len_names
S = filesnames(i);
S = S{
1};
S =strsplit(S,'.');
S = S(1);
S = S{
1};
S = str2num(S);
files(k)=S;
k = k+1;
end
files
fds_path = 'fds/';
raw_path = 'raw/';
fds2raw(fds_path,raw_path,files)#这个函数需要请下载完整程序
下面是raw转png的python代码
import cv2
import numpy as np
path_raw = 'raw/'
path_png = 'png/'
filename = '1404.raw'
imgData = np.fromfile(path_raw+filename, dtype='uint16')
imgData = imgData.reshape(12,992,1024)
filename,_ = filename.split('.')
for i in range(12):
print(i+1)
cv2.imwrite(path_png+filename+'_'+str(i)+'.png',imgData[i,:,:])
cv2.imshow('img',imgData[i,:,:])
cv2.waitKey(0)
点击此处下载完整程序