资源简介
matlab 读取envi标准格式文件,代码现成可用,只需修改输入文件目录,可读取hdf格式文件
代码片段和文件信息
function [imageptb] = freadenvi(fname)
% freadenvi - read envi image (V. Guissard Apr 29 2004)
%
% Reads an image of ENVI standard type
% to a [col x line x band] MATLAB array
% image=freadenvi(fname)
% [imagep]=freadenvi(fname)
% [imagept]=freadenvi(fname)
% [imageptb] = freadenvi(fname)
%
% INPUT :
%
% fname string giving the full pathname of the ENVI image to read.
%
% OUTPUT :
%
% image----------- c by l by b array containing the ENVI image values organised in
% c : cols l : lines and b : bands.
% p 1 by 3 vector that contains (1) the nb of cols (2) the number.
% of lines and (3) the number of bands of the opened image.
%
% t string describing the image data type string in MATLAB conventions.
% b string describing the image data interleave:bsqbil or bip
%
% NOTE : freadenvi needs the corresponding image header file generated
% automatically by ENVI. The ENVI header file must have the same name
% as the ENVI image file + the ‘.hdf‘ exention.
% Revised by Hu Shunshi2011.1.3
% can read bsqbil and bip data interleave.
%%%%%%%%%%%%%
% Parameters initialization
elements={‘samples ‘ ‘lines ‘ ‘bands ‘ ‘data type ‘ ‘interleave ‘};
d={‘bit8‘ ‘int16‘ ‘int32‘ ‘float32‘ ‘float64‘ ‘uint16‘ ‘uint32‘ ‘int64‘ ‘uint64‘};
interleave={‘bsq‘ ‘bil‘ ‘bip‘};
% Check user input
if ~ischar(fname)
error(‘fname should be a char string‘);
end
% Open ENVI header file to retreive s l b & d variables
rfid = fopen(strcat(fname‘.hdr‘)‘r‘);
% Check if the header file is correctely open
if rfid == -1
error(‘Input header file does not exist‘);
end;
% Read ENVI image header file and get p(1) : nb samples
% p(2) : nb lines p(3) : nb bands t : data type and b:interleave
while 1
tline = fgetl(rfid);
if ~ischar(tline) break end
[firstsecond]=strtok(tline‘=‘);
switch first
case elements(1)
[fs]=strtok(second);
p(1)=str2num(s);
case elements(2)
[fs]=strtok(second);
p(2)=st
相关资源
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
- k近邻算法matlab实现
- matlab识别系统
评论
共有 条评论