matlib-----mat格式文件转tif

%InputMatFileName如D:/360极速浏览器下载/Pavia.mat
%OutputTifFilename如D:/360极速浏览器下载/PaviaTIF.tif
% Mat2Tif('D:/360极速浏览器下载/Pavia.mat','D:/360极速浏览器下载/TifPavia.tif');
function Mat2Tif(InputMatFileName,OutputTifFilename)
    load(InputMatFileName);
    InputMatImg=label;
    t = Tiff(OutputTifFilename,'w');
    if size(InputMatImg,3) == 3
        t.setTag('Photometric',Tiff.Photometric.RGB);
    else
        t.setTag('Photometric',Tiff.Photometric.MinIsBlack);%颜色空间解释方式
    end
    t.setTag('Compression',Tiff.Compression.None);%无压缩
    t.setTag('BitsPerSample',64);% 由于输入.mat为double类型,所以选择了64位
    t.setTag('SamplesPerPixel',size(InputMatImg,3));% 每个像素的波段数目
    t.setTag('SampleFormat',Tiff.SampleFormat.IEEEFP);% 配合BitsPerSample64位double类型,选择IEEEFP来对应
    t.setTag('ImageLength',size(InputMatImg,1));% 影像宽度
    t.setTag('ImageWidth',size(InputMatImg,2));% 影像高度
    t.setTag('PlanarConfiguration',Tiff.PlanarConfiguration.Chunky);%平面配置选择集中式
    t.write(InputMatImg);% 准备好了头文件,开始写影像数据
    t.close();% 关闭影像

新建一个脚本文件,输入上述代码。命令行窗口输入

%%其中soup_bigcorn_orange_1ms.mat格式为64位浮点数
Mat2Tif('soup_bigcorn_orange_1ms.mat', 'soup_bigcorn_orange_1ms.tif')

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值