赞
踩
由于近期需要使用Hyperspectral Remote Sensing Scenes中的高光谱数据,所以特地记录一下数据处理的过程。
由于Mat文件时MATLAB中特有的文件,所以需要敲一些代码,但是整个过程是比较简单的,如下所示。
clc clear close all %获取Mat文件 [fileName,pathName]=uigetfile('*.mat','Input Data-File'); if isempty(fileName) || length(fileName) == 1 fprintf("未选择mat文件!\n"); return; end fullPath = [pathName,fileName]; % load(fullPath); image = importdata(fullPath); shape = size(image); dirName = fileName(1:length(fileName)-4); dirPath = [pathName,dirName]; if exist(dirPath,'dir')==0 mkdir(dirPath); end if length(shape) < 3 fprintf("该文件不是多光谱数据\n"); image = uint16(image); %将灰度值转换为16bit str = [dirPath,'\',dirName,'.tif']; imwrite(image,str,'tif'); return; end fprintf("输入数据的波段数量%d\n",shape(3)); for i=1:shape(3) band = image(:,:,i); band = uint16(band); %将灰度值转换为16bit str=sprintf('B%d.tif',i); str = [dirPath,'\',dirName,str]; imwrite(band,str,'tif'); fprintf("输出波段%d\n",i); end
处理之后的效果:
特别要注意的是,灰度值要转换成16bit深度,否则有的影像呈现出来会全是黑色。此外就是这种转换出的tif文件是没有地理坐标的,所以如果要使用ENVI进行波段融合,还需要手动的进行地理配准*^*。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。