资源简介
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
相关资源
- 局部加权回归的MATLAB实现机器学习之
- 《SeDuMi — 基于matlab的优化软件》帮助
- 图像分类matlab代码
- MATLAB 曲面拟合
- Matlab Hu矩7个不变矩源码
- NURBS_MATLAB
- matlab_非线性时滞系统的仿真程序
- 卷积码仿真程序matlab仿真,得到误码
- SCMA调制解调matlab仿真代码
- PID控制器与状态反馈控制器MATLAB教学
- MATLAB实现人眼定位程序
- DCO_OFDM程序代码
- Matlab生成Voronoi图代码
-
将txt转成voc数据集标准xm
lmatlab的 - MATLAB实现DCCA算法
- MATLAB环境下的基于HMM模型的语音识别
- SAR雷达回波仿真matlab
- MATLAB GUI实现动态画图曲线的源程序代
- 雨流计数法MATLAB源码
- 24脉波整流matlab仿真
- matlab图像特征点匹配
- 归一化8点算法-MATLAB代码
- 基于MATLAB的KAPPA系数计算
- 构造均值为a方差为b的高斯白噪声
- FCM模糊聚类matlab代码
- 室内定位算法matlab程序
- 基于4个特征的阴影检测算法
- GN算法,matlab
- ZEMAX 与MATLAB的接口技术
- 恒压频比交流调速MATLAB仿真
评论
共有 条评论