1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > matlab将mat格式高光谱图像转为tif格式

matlab将mat格式高光谱图像转为tif格式

时间:2024-07-02 06:07:59

相关推荐

matlab将mat格式高光谱图像转为tif格式

高光谱图像mat格式转为tif格式

以高光谱IndiaP数据为例,保存为200个波段的tif文件。ENVI软件只能读入tif格式的遥感图像数据

% mat2tif% 将高光谱mat文件,保存为tifclc; clear; close all;%% load the hyperspectral imagepath = './';dataset = 'IndiaP';location = [path, dataset];load (location);% 获取数组维度信息[row, col, bands] = size(img);% double类型转unit8img_8 = uint8(img(:,:,:)/10000*256);% 保存为tif图像t = Tiff('imageIndiaP.tif','w');% 影像信息tagstruct.ImageLength = size(img_8,1); tagstruct.ImageWidth = size(img_8,2); % 颜色空间解释方式tagstruct.Photometric = 1;% 每个像素的数值位数,这里转换为unit8,所以为8位tagstruct.BitsPerSample = 8;% 每个像素的波段个数,一般图像为1或3,但是对于遥感影像存在多个波段所以常常大于3tagstruct.SamplesPerPixel = bands;tagstruct.RowsPerStrip = 16;tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;% 表示生成影像的软件tagstruct.Software = 'MATLAB'; % 表示对数据类型的解释tagstruct.SampleFormat = 1;% 设置Tiff对象的tagt.setTag(tagstruct);% 以准备好头文件,开始写数据t.write(img_8);% 关闭影像t.close;

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。