matlab读取高光谱影像
1.函数multibandread读取读取多波段二进制影像文件(ENVI主菜单file—save file as—envi standard得到的就是二进制影像文件,有时甚至会看到后缀名为bsq、bil、bip等影像)。
im_hyper = multibandread(filename, size, precision, offset, interleave, byteorder)
后附参考代码有实例
precision='uint8=>uint8';%头文件中datatype=1对应ENVI中数据类型为Byte,对应MATLAB中数据类型为uint8
precision='int16=>int16';%头文件中datatype=2对应ENVI中数据类型为Integer,对应MATLAB中数据类型为int16
precision='uint16=>uint16';%头文件中datatype=12对应ENVI中数据类型为Unsighed Int,对应MATLAB中数据类型为uint16
precision='int32=>int32';%头文件中datatype=3对应ENVI中数据类型为Long Integer,对应MATLAB中数据类型为int32
precision='uint32=>uint32';%头文件中datatype=13对应ENVI中数据类型为Unsighed Long,对应MATLAB中数据类型为uint32
precision='float32=>float32';%头文件中datatype=4对应ENVI中数据类型为Floating Point,对应MATLAB中数据类型为float32
precision='double=>double';%头文件中datatype=5对应ENVI中数据类型为Double Precision,对应MATLAB中数据类型为double
)
function data=read_ENVIimagefile(imgfilename) %本函数读取img格式,前提是img图像显式带有'.img'后缀名。 if length(imgfilename)>=4 switch strcmp(imgfilename(length(imgfilename)-3:end), '.img') case 0 hdrfilename=strcat(imgfilename, '.hdr'); case 1 hdrfilename=strcat(imgfilename(1: (length(imgfilename)-4)), '.hdr'); end else hdrfilename=strcat(imgfilename, '.hdr'); end %读取ENVI标准格式图像文件 %读取图像头文件 fid = fopen(hdrfilename, 'r'); info = fread(fid,'char=>char'); info=info';%默认读入列向量,须要转置为行向量才适于显示 fclose(fid); %查找列数 a=strfind(info,'samples = '); b=length('samples = '); c=strfind(info,'lines'); samples=[]; for i=a+b:c-1 samples=[samples,info(i)]; end samples=str2num(samples); %查找行数 a=strfind(info,'lines = '); b=length('lines = '); c=strfind(info,'bands'); lines=[]; for i=a+b:c-1 lines=[lines,info(i)]; end lines=str2num(lines); %查找波段数 a=strfind(info,'bands = '); b=length('bands = '); c=strfind(info,'header offset'); bands=[]; for i=a+b:c-1 bands=[bands,info(i)]; end bands=str2num(bands); %查找数据类型 a=strfind(info,'data type = '); b=length('data type = '); c=strfind(info,'interleave'); datatype=[]; for i=a+b:c-1 datatype=[datatype,info(i)]; end datatype=str2num(datatype); precision=[]; switch datatype case 1 precision='uint8=>uint8';%头文件中datatype=1对应ENVI中数据类型为Byte,对应MATLAB中数据类型为uint8 case 2 precision='int16=>int16';%头文件中datatype=2对应ENVI中数据类型为Integer,对应MATLAB中数据类型为int16 case 12 precision='uint16=>uint16';%头文件中datatype=12对应ENVI中数据类型为Unsighed Int,对应MATLAB中数据类型为uint16 case 3 precision='int32=>int32';%头文件中datatype=3对应ENVI中数据类型为Long Integer,对应MATLAB中数据类型为int32 case 13 precision='uint32=>uint32';%头文件中datatype=13对应ENVI中数据类型为Unsighed Long,对应MATLAB中数据类型为uint32 case 4 precision='float32=>float32';%头文件中datatype=4对应ENVI中数据类型为Floating Point,对应MATLAB中数据类型为float32 case 5 precision='double=>double';%头文件中datatype=5对应ENVI中数据类型为Double Precision,对应MATLAB中数据类型为double otherwise error('invalid datatype');%除以上几种常见数据类型之外的数据类型视为无效的数据类型 end %查找数据格式 a=strfind(info,'interleave = '); b=length('interleave = '); c=strfind(info,'sensor type'); interleave=[]; for i=a+b:c-1 interleave=[interleave,info(i)]; end interleave=strtrim(interleave);%删除字符串中的空格 %读取图像文件 fid = fopen(imgfilename, 'r'); data = multibandread(imgfilename ,[lines, samples, bands],precision,0,interleave,'ieee-le'); data= double(data); end
转载于:https://www.cnblogs.com/shyzh/p/10413503.html
matlab读取高光谱影像相关推荐
- 基于MATLAB读取高光谱影像每个像素的光谱信息
1.安装高光谱工具箱 首先,利用MATLAB对高光谱影像进行处理需要安装高光谱工具箱,这要求MATLAB版本至少为2020版本及以上,否则会出现不兼容的问题. 下载地址:https://ww2.mat ...
- 基于python的Spectral模块读取高光谱影像信息的一些笔记
1. 安装spectral模块 spectral模块的安装需要有numpy.pillow.wxpython.matplotlib.ipython等这几个包的铺垫,而且安装spectral模块时看的教程 ...
- MATLAB读取高光谱数据
只能读取dat类型的高光谱数据 以下为头文件 clc clear all close allhdr = read_envihdr('d.hdr'); Image = multibandread('d. ...
- Matlab 高光谱影像信息熵/信噪比计算
高光谱影像信息熵/信噪比计算 基于matlab实现了高光谱影像个波段信噪比和信息熵的计算 文件导入:影像格式使用的ENVI导出的img+hdr格式,参考的Matlab实现高光谱读取进行的修改.时间伧俗 ...
- matlab 光谱噪声,环境小卫星高光谱影像条纹噪声去除程序IDL版
前言 源代码 PRO stripe_remove1 ENVI,/Restore_Base_Save_Files ENVI_Batch_init file = DIALOG_PICKFILE(/READ ...
- 高光谱影像伪彩色显示
高光谱影像有几十个甚至上百个光谱通道,我们并不能直接显示高光谱影像,但如果我们知道R.G.B这三个波段的,便能够实现伪彩色影像显示. 以下是基于Matlab实现的伪彩色显示高光谱影像的函数 funct ...
- matlab 显示高光谱,高光谱图像显示问题
matlab打开遥感数据 注:两种方式产生的数据矩阵相等,经过isequal函数验证. 1.遥感数据用envi保存为tiff格式,再用matlab打开 2.用multibandread函数读取,要利用 ...
- 利用MATLAB 实现高光谱影像区域截取操作
利用MATLAB 实现高光谱影像区域截取操作 前言: 1.相关函数说明 2. Matlab 代码 3. 具体效果 后记 欢迎学习交流! 邮箱: z-@1-6.com 网站: https://zephy ...
- 利用 MATLAB 彩色显示高光谱图像(伪彩色,真彩色)
利用 MATLAB 彩色显示高光谱图像(伪彩色,真彩色) 前言 一.使用imshow函数彩色显示高光谱图像 注意事项: 欢迎学习交流! 邮箱: z-@1-6.com 网站: https://zephy ...
最新文章
- 【软件开发】制作个人移动式Git服务器
- C#LeetCode刷题之#617-合并二叉树​​​​​​​​​​​​​​(Merge Two Binary Trees)
- css 实现背景图片拉伸
- MAC下ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
- 2017年3月份前端资源分享
- 自动化测试与DevOps以及持续集成的关系。
- (day 26 - 广度优先搜索 )剑指 Offer 32 - III. 从上到下打印二叉树 III
- 写代码:实现用户输入用户名和密码,当用户名为seven且密码为123时,显示登录成功,否则失败,失败时允许重复输入三次。...
- 微博爬虫思路:Python通过移动端接口爬取,简单易操作
- 最近大火的「元宇宙」是什么?
- java i586什么意思_linux里面i386 i686 i486 i586代表什么?是什么意思
- 谷歌翻译是如何获得突破性进展?
- Python学习(二)列表,for循环,切片,元组
- 第一讲:最能入门的爬虫教程(Python实现)
- Android LCD(一):LCD基本原理篇(一/四)
- [NOI2008] 假面舞会
- SOD下载数据注意事项
- The 2017 ACM-ICPC Asia East Continent League Final记录
- 定期存款计算器_定期存款预测
- html免费编辑器图片alt,织梦模板kindeditor编辑器图片上传增加图片说明alt属性和title属性...
热门文章
- Android Media (Audio) Framework 多媒体系统框架
- Linux IO 多路复用是什么意思?
- UVa 1583 Digit Generator(枚举+打表)
- 字符串和datatime.time类型转为秒
- 调用Interop.zkemkeeper.dll无法使用解决方案
- SmartTimer的开发思路
- nginx proxy模块
- PHP 二分查找(详细)
- Ajax补充之serialize
- leetcode 802. 找到最终的安全状态(Find Eventual Safe States)