高光谱图像mat2tiff

1、前言

研究需要需要展示高光谱图像的3维立体图,因此用chatgpt帮忙写了一个。用于转换HSI CD的.mat格式的数据集。

2-代码

%%
clc; clear; close all;
% load the hyperspectral image
img = load ('USA_Change_Dataset.mat'); 
img = img.T1;
% 提取高光谱数据的维度信息
[rows, cols, bands] = size(img); % 替换为你的高光谱数据变量名

% 创建一个空白的TIFF图像
tiff_img = zeros(rows, cols, bands, 'uint16'); % 使用uint16数据类型以保留高光谱数据的精度

% 将高光谱数据复制到TIFF图像中
for band = 1:bands
    tiff_img(:,:,band) = img(:,:,band);
end

% 保存TIFF图像
tiff_filename = 'output_image.tif'; % 替换为你想要保存的TIFF文件名和路径
t = Tiff(tiff_filename, 'w');

% 设置TIFF图像的属性
tagstruct.ImageLength = size(tiff_img, 1);
tagstruct.ImageWidth = size(tiff_img, 2);
tagstruct.Photometric = Tiff.Photometric.MinIsBlack;
tagstruct.BitsPerSample = 16;
tagstruct.SamplesPerPixel = bands;
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
tagstruct.ExtraSamples = Tiff.ExtraSamples.Unspecified;
tagstruct.Software = 'MATLAB';

% 写入图像数据
t.setTag(tagstruct);
t.write(tiff_img);
t.close();

disp('MAT格式的高光谱数据已成功转换为TIFF格式!');

3-ENVI效果展示

ENVI将读取tiff格式图像,然后展示3维立体图
在这里插入图片描述

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值