forked from Link-dev/ENVI_readAndWrite
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenviread.m
37 lines (31 loc) · 1.06 KB
/
enviread.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function [D,info]=enviread(datafile,hdrfile)
%ENVIREAD Reads ENVI image file.
%[D,INFO]=ENVIREAD(DATAFILE,HDRFILE) provides images data (D) and a
%structure (INFO) whose fields correspond to header items.
%[D,INFO]=ENVIREAD(DATAFILE) assumes the header file is named
%"DATAFILE.hdr" and exists in the same directory.
%D will be in whatever number format (double, int, etc.) as in the ENVI
%file.
%Original version by Ian Howat, Ohio State Universtiy, [email protected]
%Thanks to Yushin Ahn and Ray Jung
%Heavily modified by Felix Totir.
if nargin < 1
error('You must specify at least one input');
elseif nargin <2
[path, dataName, extensionName] = fileparts(datafile);
if isempty(extensionName)
hdrfile=[deblank(datafile),'.hdr']; %implicit name
else
if isempty(path)
hdrfile=[deblank(dataName),'.hdr'];
else
hdrfile=[path '/' deblank(dataName),'.hdr'];
end
end
end
if exist(hdrfile, 'file')
info=envihdrread(hdrfile);
D=envidataread(datafile,info);
else
[D, info]=envitifread(datafile);
end