Code covered by the BSD License  

Highlights from
ENVI file reader/writer

5.0

5.0 | 1 rating Rate this file 52 Downloads (last 30 days) File Size: 7.38 KB File ID: #27172

ENVI file reader/writer

by Felix Totir

 

05 Apr 2010 (Updated 26 Jul 2010)

Mini-toolbox for reading and writing ENVI data and header files (including complex).

| Watch this File

File Information
Description

%test script

%clears workspace
clearvars;

%generate a complex 3-D variable
D=rand(2,3,4)+j*rand(2,3,4);

%create basic ENVI header info about a Matlab variable
info=enviinfo(D);

%write the variable and the associated header info in a pair of binary/header ENVI files
enviwrite(D,info,'a.dat'); %implicit header file is "a.dat.hdr" (if not explicitly passed)

%read a complex n-D variable from "a.dat" and "a.dat.hdr" ENVI files
[D2,info2]=enviread('a.dat');

%some comparisons to validate consistency of our read/write procedures
isequal(D,D2)
isequal(info,info2)

%modify the header info (introducing offset in ENVI header)
info3=info2;
info3.header_offset=10000;
D3=D2; %same as D2

%writing the D3 (same as D2), but with 10000 offset
enviwrite(D3,info3,'a3.dat');

%read the offset variable (D3)
[D3a,info3a]=enviread('a3.dat');

%comparisons to validate read/write
isequal(D3,D3a)
isequal(info3,info3a)

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
ENVI to MATLAB, MATLAB to ENVI, ENVI file reader, updated 2/9/2010, READ_ENVIHDR

MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
30 Nov 2010 Margaret

Very useful for importing ENVI standard files into Matlab as well as outputing the results from a Matlab analysis back to ENVI! Runs fast - no compatibility issues with large files.

18 Jan 2012 Jaroslaw Tuszynski

A better option is to use MATLAB's multibandread function

18 Jan 2012 Felix Totir

@Jaroslaw Tuszynski: The provided function envidataread.m is esentially a wrapper around multibandread(). Even a hint towards multibandread is given in the comments on lines 88 and 90 of that function (please have a look at the code).

However, using multibandread alone requires *reading the header by a human*. The purpose of this little toolbox is exactly to automatize that operation (working with headers and data).

Please login to add a comment or rating.
Updates
26 Jul 2010

improved description

Tag Activity for this File
Tag Applied By Date/Time
envi Felix Totir 06 Apr 2010 10:22:09
cxf Felix Totir 06 Apr 2010 10:22:09
data import Felix Totir 06 Apr 2010 10:22:09
data export Felix Totir 06 Apr 2010 10:22:09
matlab to envi Felix Totir 17 Jun 2010 00:37:27
write Felix Totir 17 Jun 2010 00:37:27
read Felix Totir 17 Jun 2010 00:37:27
envi to matlab Felix Totir 17 Jun 2010 00:37:28

Contact us at files@mathworks.com